From f74a6b4b5777211dcda979b0e390305f46efdd95 Mon Sep 17 00:00:00 2001 From: Brenden Bice Date: Tue, 9 Apr 2019 04:00:09 -0400 Subject: [PATCH] display favs & reblogged users on expanded post in timeline view --- src/components/conversation/conversation.js | 7 ++-- src/components/timeline/timeline.vue | 1 + src/modules/statuses.js | 40 ++++++++++++++------- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 1e75feb9..5cc7f4ee 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -41,7 +41,8 @@ const conversation = { props: [ 'statusoid', 'collapsable', - 'isPage' + 'isPage', + 'timelineName' ], created () { if (this.isPage) { @@ -120,8 +121,8 @@ const conversation = { if (this.status) { this.$store.state.api.backendInteractor.fetchConversation({id: this.status.id}) .then(({ancestors, descendants}) => { - this.$store.dispatch('fetchFavoritedByUsers', { id: this.status.id }) - this.$store.dispatch('fetchRebloggedByUsers', { id: this.status.id }) + this.$store.dispatch('fetchFavoritedByUsers', { id: this.statusId, retweetedStatusId: this.status.id, timelineName: this.timelineName }) + this.$store.dispatch('fetchRebloggedByUsers', { id: this.statusId, retweetedStatusId: this.status.id, timelineName: this.timelineName }) this.$store.dispatch('addNewStatuses', { statuses: ancestors }) this.$store.dispatch('addNewStatuses', { statuses: descendants }) }) diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue index e0a34bd1..147e8a1d 100644 --- a/src/components/timeline/timeline.vue +++ b/src/components/timeline/timeline.vue @@ -22,6 +22,7 @@ :key="status.id" :statusoid="status" :collapsable="true" + :timelineName="timelineName" /> diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 44213e75..023f132e 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -460,16 +460,32 @@ export const mutations = { queueFlush (state, { timeline, id }) { state.timelines[timeline].flushMarker = id }, - addFavoritedByUsers (state, { favoritedByUsers, id }) { - state.allStatusesObject[id] = { - ...state.allStatusesObject[id], - favoritedBy: favoritedByUsers + addFavoritedByUsers (state, { favoritedByUsers, id, timelineName }) { + if (timelineName) { + state.timelines[timelineName].visibleStatusesObject[id] = { + ...state.timelines[timelineName].visibleStatusesObject[id], + favoritedBy: favoritedByUsers + } + state.timelines[timelineName].visibleStatuses = state.timelines[timelineName].visibleStatuses.map(visibleStatus => visibleStatus.id === id ? { ...visibleStatus, favoritedBy: favoritedByUsers } : visibleStatus) + } else { + state.allStatusesObject[id] = { + ...state.allStatusesObject[id], + favoritedBy: favoritedByUsers + } } }, - addRebloggedByUsers (state, { rebloggedByUsers, id }) { - state.allStatusesObject[id] = { - ...state.allStatusesObject[id], - rebloggedBy: rebloggedByUsers + addRebloggedByUsers (state, { rebloggedByUsers, id, timelineName }) { + if (timelineName) { + state.timelines[timelineName].visibleStatusesObject[id] = { + ...state.timelines[timelineName].visibleStatusesObject[id], + rebloggedBy: rebloggedByUsers + } + state.timelines[timelineName].visibleStatuses = state.timelines[timelineName].visibleStatuses.map(visibleStatus => visibleStatus.id === id ? { ...visibleStatus, rebloggedBy: rebloggedByUsers } : visibleStatus) + } else { + state.allStatusesObject[id] = { + ...state.allStatusesObject[id], + rebloggedBy: rebloggedByUsers + } } } } @@ -537,11 +553,11 @@ const statuses = { credentials: rootState.users.currentUser.credentials }) }, - fetchFavoritedByUsers ({ rootState, commit }, { id }) { - rootState.api.backendInteractor.fetchFavoritedByUsers({id}).then((favoritedByUsers) => commit('addFavoritedByUsers', { favoritedByUsers, id })) + fetchFavoritedByUsers ({ rootState, commit }, { id, retweetedStatusId, timelineName }) { + rootState.api.backendInteractor.fetchFavoritedByUsers({id}).then((favoritedByUsers) => commit('addFavoritedByUsers', { favoritedByUsers, id: retweetedStatusId, timelineName })) }, - fetchRebloggedByUsers ({ rootState, commit }, { id }) { - rootState.api.backendInteractor.fetchRebloggedByUsers({id}).then((rebloggedByUsers) => commit('addRebloggedByUsers', { rebloggedByUsers, id })) + fetchRebloggedByUsers ({ rootState, commit }, { id, retweetedStatusId, timelineName }) { + rootState.api.backendInteractor.fetchRebloggedByUsers({id}).then((rebloggedByUsers) => commit('addRebloggedByUsers', { rebloggedByUsers, id: retweetedStatusId, timelineName })) } }, mutations