From bda0a76c89cadc6251261a08575acf6986da1084 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 12 Jun 2017 16:30:56 +0200 Subject: [PATCH] Clear timeline on user change. --- src/components/user_profile/user_profile.js | 1 + src/modules/statuses.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index 5eef2735..3d473592 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -3,6 +3,7 @@ import Timeline from '../timeline/timeline.vue' const UserProfile = { created () { + this.$store.commit('clearTimeline', { timeline: 'user' }) this.$store.dispatch('startFetching', ['user', this.userId]) }, destroyed () { diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 372567c5..0b4069c6 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -295,6 +295,21 @@ export const mutations = { oldTimeline.visibleStatusesObject = {} each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status }) }, + clearTimeline (state, { timeline }) { + const emptyTimeline = { + statuses: [], + statusesObject: {}, + faves: [], + visibleStatuses: [], + visibleStatusesObject: {}, + newStatusCount: 0, + maxId: 0, + minVisibleId: 0, + loading: false + } + + state.timelines[timeline] = emptyTimeline + }, setFavorited (state, { status, value }) { const newStatus = state.allStatusesObject[status.id] newStatus.favorited = value