From a8f6099be22a1eff4267c859f3954c1a22e3e793 Mon Sep 17 00:00:00 2001 From: shpuld Date: Tue, 8 Jan 2019 23:09:03 +0200 Subject: [PATCH 1/2] Retain userId on clearing user timeline, don't flush when empty timeline --- src/modules/statuses.js | 2 ++ src/services/timeline_fetcher/timeline_fetcher.service.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index dccccf72..b7560f1c 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -346,7 +346,9 @@ export const mutations = { each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status }) }, clearTimeline (state, { timeline }) { + const userId = state.timelines[timeline].userId state.timelines[timeline] = emptyTl() + state.timelines[timeline].userId = userId }, setFavorited (state, { status, value }) { const newStatus = state.allStatusesObject[status.id] diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index c2a7de56..727f6c60 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -31,7 +31,7 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false return apiService.fetchTimeline(args) .then((statuses) => { - if (!older && statuses.length >= 20 && !timelineData.loading) { + if (!older && statuses.length >= 20 && !timelineData.loading && timelineData.statuses.length) { store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId }) } update({store, statuses, timeline, showImmediately, userId}) From b8b18b198db1bac639c8310ea97f317be17e1c5a Mon Sep 17 00:00:00 2001 From: shpuld Date: Wed, 9 Jan 2019 22:19:02 +0200 Subject: [PATCH 2/2] Change emptlyTl to take userId --- src/modules/statuses.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index b7560f1c..f92239a9 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -2,7 +2,7 @@ import { includes, remove, slice, sortBy, toInteger, each, find, flatten, maxBy, import apiService from '../services/api/api.service.js' // import parse from '../services/status_parser/status_parser.js' -const emptyTl = () => ({ +const emptyTl = (userId = 0) => ({ statuses: [], statusesObject: {}, faves: [], @@ -14,8 +14,8 @@ const emptyTl = () => ({ loading: false, followers: [], friends: [], - userId: 0, - flushMarker: 0 + flushMarker: 0, + userId }) export const defaultState = { @@ -346,9 +346,7 @@ export const mutations = { each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status }) }, clearTimeline (state, { timeline }) { - const userId = state.timelines[timeline].userId - state.timelines[timeline] = emptyTl() - state.timelines[timeline].userId = userId + state.timelines[timeline] = emptyTl(state.timelines[timeline].userId) }, setFavorited (state, { status, value }) { const newStatus = state.allStatusesObject[status.id]