Code refactoring
This commit is contained in:
parent
19870c0b6d
commit
0dc7c45f32
@ -7,7 +7,7 @@ const PublicAndExternalTimeline = {
|
|||||||
timeline () { return this.$store.state.statuses.timelines.publicAndExternal }
|
timeline () { return this.$store.state.statuses.timelines.publicAndExternal }
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.$store.dispatch('startFetching', 'publicAndExternal')
|
this.$store.dispatch('startFetching', { timeline: 'publicAndExternal' })
|
||||||
},
|
},
|
||||||
destroyed () {
|
destroyed () {
|
||||||
this.$store.dispatch('stopFetching', 'publicAndExternal')
|
this.$store.dispatch('stopFetching', 'publicAndExternal')
|
||||||
|
@ -7,7 +7,7 @@ const PublicTimeline = {
|
|||||||
timeline () { return this.$store.state.statuses.timelines.public }
|
timeline () { return this.$store.state.statuses.timelines.public }
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.$store.dispatch('startFetching', 'public')
|
this.$store.dispatch('startFetching', { timeline: 'public' })
|
||||||
},
|
},
|
||||||
destroyed () {
|
destroyed () {
|
||||||
this.$store.dispatch('stopFetching', 'public')
|
this.$store.dispatch('stopFetching', 'public')
|
||||||
|
@ -3,7 +3,7 @@ import Timeline from '../timeline/timeline.vue'
|
|||||||
const TagTimeline = {
|
const TagTimeline = {
|
||||||
created () {
|
created () {
|
||||||
this.$store.commit('clearTimeline', { timeline: 'tag' })
|
this.$store.commit('clearTimeline', { timeline: 'tag' })
|
||||||
this.$store.dispatch('startFetching', { 'tag': this.tag })
|
this.$store.dispatch('startFetching', { timeline: 'tag', tag: this.tag })
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
Timeline
|
Timeline
|
||||||
@ -15,7 +15,7 @@ const TagTimeline = {
|
|||||||
watch: {
|
watch: {
|
||||||
tag () {
|
tag () {
|
||||||
this.$store.commit('clearTimeline', { timeline: 'tag' })
|
this.$store.commit('clearTimeline', { timeline: 'tag' })
|
||||||
this.$store.dispatch('startFetching', { 'tag': this.tag })
|
this.$store.dispatch('startFetching', { timeline: 'tag', tag: this.tag })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
destroyed () {
|
destroyed () {
|
||||||
|
@ -8,8 +8,8 @@ const UserProfile = {
|
|||||||
this.$store.commit('clearTimeline', { timeline: 'user' })
|
this.$store.commit('clearTimeline', { timeline: 'user' })
|
||||||
this.$store.commit('clearTimeline', { timeline: 'favorites' })
|
this.$store.commit('clearTimeline', { timeline: 'favorites' })
|
||||||
this.$store.commit('clearTimeline', { timeline: 'media' })
|
this.$store.commit('clearTimeline', { timeline: 'media' })
|
||||||
this.$store.dispatch('startFetching', ['user', this.fetchBy])
|
this.$store.dispatch('startFetching', { timeline: 'user', userId: this.fetchBy })
|
||||||
this.$store.dispatch('startFetching', ['media', this.fetchBy])
|
this.$store.dispatch('startFetching', { timeline: 'media', userId: this.fetchBy })
|
||||||
this.startFetchFavorites()
|
this.startFetchFavorites()
|
||||||
if (!this.user.id) {
|
if (!this.user.id) {
|
||||||
this.$store.dispatch('fetchUser', this.fetchBy)
|
this.$store.dispatch('fetchUser', this.fetchBy)
|
||||||
@ -63,12 +63,12 @@ const UserProfile = {
|
|||||||
methods: {
|
methods: {
|
||||||
startFetchFavorites () {
|
startFetchFavorites () {
|
||||||
if (this.isUs) {
|
if (this.isUs) {
|
||||||
this.$store.dispatch('startFetching', ['favorites', this.fetchBy])
|
this.$store.dispatch('startFetching', { timeline: 'favorites', userId: this.fetchBy })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
startUp () {
|
startUp () {
|
||||||
this.$store.dispatch('startFetching', ['user', this.fetchBy])
|
this.$store.dispatch('startFetching', { timeline: 'user', userId: this.fetchBy })
|
||||||
this.$store.dispatch('startFetching', ['media', this.fetchBy])
|
this.$store.dispatch('startFetching', { timeline: 'media', userId: this.fetchBy })
|
||||||
|
|
||||||
this.startFetchFavorites()
|
this.startFetchFavorites()
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
|
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
|
||||||
import { isArray } from 'lodash'
|
|
||||||
import { Socket } from 'phoenix'
|
import { Socket } from 'phoenix'
|
||||||
|
|
||||||
const api = {
|
const api = {
|
||||||
@ -34,26 +33,12 @@ const api = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
startFetching (store, payload) {
|
startFetching (store, {timeline = 'friends', tag = false, userId = false}) {
|
||||||
let userId = false
|
|
||||||
let timeline = 'friends'
|
|
||||||
let tag = false
|
|
||||||
|
|
||||||
if (isArray(payload)) {
|
|
||||||
// For user timelines
|
|
||||||
timeline = payload[0]
|
|
||||||
userId = payload[1]
|
|
||||||
} else if (payload.tag) {
|
|
||||||
// For tag timelines
|
|
||||||
timeline = 'tag'
|
|
||||||
tag = payload.tag
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't start fetching if we already are.
|
// Don't start fetching if we already are.
|
||||||
if (!store.state.fetchers[timeline]) {
|
if (store.state.fetchers[timeline]) return
|
||||||
const fetcher = store.state.backendInteractor.startFetching({timeline, store, userId, tag})
|
|
||||||
store.commit('addFetcher', {timeline, fetcher})
|
const fetcher = store.state.backendInteractor.startFetching({ timeline, store, userId, tag })
|
||||||
}
|
store.commit('addFetcher', { timeline, fetcher })
|
||||||
},
|
},
|
||||||
stopFetching (store, timeline) {
|
stopFetching (store, timeline) {
|
||||||
const fetcher = store.state.fetchers[timeline]
|
const fetcher = store.state.fetchers[timeline]
|
||||||
|
@ -271,7 +271,7 @@ const users = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start getting fresh posts.
|
// Start getting fresh posts.
|
||||||
store.dispatch('startFetching', 'friends')
|
store.dispatch('startFetching', { timeline: 'friends' })
|
||||||
|
|
||||||
// Get user mutes and follower info
|
// Get user mutes and follower info
|
||||||
store.rootState.api.backendInteractor.fetchMutes().then((mutedUsers) => {
|
store.rootState.api.backendInteractor.fetchMutes().then((mutedUsers) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user