Fix issue while fetching timelines for tag page

This commit is contained in:
Edijs 2019-02-06 19:19:43 -07:00
parent fafe258f2b
commit 19870c0b6d

View file

@ -1,5 +1,5 @@
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 { isArray } from 'lodash'
import { Socket } from 'phoenix' import { Socket } from 'phoenix'
const api = { const api = {
@ -34,18 +34,24 @@ const api = {
} }
}, },
actions: { actions: {
startFetching (store, timeline) { startFetching (store, payload) {
let userId = false let userId = false
let timeline = 'friends'
let tag = false
// This is for user timelines if (isArray(payload)) {
if (isArray(timeline)) { // For user timelines
userId = timeline[1] timeline = payload[0]
timeline = timeline[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]) {
const fetcher = store.state.backendInteractor.startFetching({timeline, store, userId}) const fetcher = store.state.backendInteractor.startFetching({timeline, store, userId, tag})
store.commit('addFetcher', {timeline, fetcher}) store.commit('addFetcher', {timeline, fetcher})
} }
}, },