Add userId property to timelines so that we don't overwrite user timeline meant

for another user
This commit is contained in:
Henry Jameson 2018-12-03 09:29:33 +03:00
parent e15b9bddbb
commit ccb1682379
3 changed files with 16 additions and 5 deletions

View file

@ -2,13 +2,14 @@ import { camelCase } from 'lodash'
import apiService from '../api/api.service.js'
const update = ({store, statuses, timeline, showImmediately}) => {
const update = ({store, statuses, timeline, showImmediately, userId}) => {
const ccTimeline = camelCase(timeline)
store.dispatch('setError', { value: false })
store.dispatch('addNewStatuses', {
timeline: ccTimeline,
userId,
statuses,
showImmediately
})
@ -33,7 +34,7 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false
if (!older && statuses.length >= 20 && !timelineData.loading) {
store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId })
}
update({store, statuses, timeline, showImmediately})
update({store, statuses, timeline, showImmediately, userId})
}, () => store.dispatch('setError', { value: true }))
}
@ -41,6 +42,7 @@ const startFetching = ({timeline = 'friends', credentials, store, userId = false
const rootState = store.rootState || store.state
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
const showImmediately = timelineData.visibleStatuses.length === 0
timelineData.userId = userId
fetchAndUpdate({timeline, credentials, store, showImmediately, userId, tag})
const boundFetchAndUpdate = () => fetchAndUpdate({ timeline, credentials, store, userId, tag })
return setInterval(boundFetchAndUpdate, 10000)