diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2020-02-10 14:08:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-10 14:08:21 +0300 |
commit | 0c71d2fcb14c1f364f61ea672bc279b830e91a4a (patch) | |
tree | d60480d1e1af5044f8f907b745200433c4ad1d56 | |
parent | d5224557410b9e6d92fd27db99b4dad5cf8c537b (diff) | |
parent | cecd364bfabcc06242a27ef7c57fbcf4f95e26bf (diff) |
Merge pull request #2930 from nextcloud/backport/2924/stable18
[stable18] Fix vuex store modification issue
4 files changed, 30 insertions, 11 deletions
diff --git a/src/components/LeftSidebar/ConversationsList/Conversation.vue b/src/components/LeftSidebar/ConversationsList/Conversation.vue index 2d7a5fbb1..1a27b24a6 100644 --- a/src/components/LeftSidebar/ConversationsList/Conversation.vue +++ b/src/components/LeftSidebar/ConversationsList/Conversation.vue @@ -104,7 +104,10 @@ import AppContentListItem from './AppContentListItem/AppContentListItem' import AppNavigationCounter from '@nextcloud/vue/dist/Components/AppNavigationCounter' import ConversationIcon from './../../ConversationIcon' import { joinConversation, removeCurrentUserFromConversation } from '../../../services/participantsService' -import { deleteConversation, addToFavorites, removeFromFavorites, setNotificationLevel } from '../../../services/conversationsService' +import { + deleteConversation, + setNotificationLevel, +} from '../../../services/conversationsService' import { generateUrl } from '@nextcloud/router' import { CONVERSATION, PARTICIPANT } from '../../../constants' @@ -330,13 +333,7 @@ export default { } }, async toggleFavoriteConversation() { - if (this.item.isFavorite) { - await removeFromFavorites(this.item.token) - } else { - await addToFavorites(this.item.token) - } - - this.item.isFavorite = !this.item.isFavorite + this.$store.dispatch('toggleFavorite', this.item) }, /** * Set the notification level for the conversation diff --git a/src/components/LeftSidebar/ConversationsList/ConversationsList.vue b/src/components/LeftSidebar/ConversationsList/ConversationsList.vue index 462867ee9..feb5f2332 100644 --- a/src/components/LeftSidebar/ConversationsList/ConversationsList.vue +++ b/src/components/LeftSidebar/ConversationsList/ConversationsList.vue @@ -143,7 +143,7 @@ export default { // Emit the click event so the search text in the leftsidebar can be reset. handleConversationClick() { this.$emit('click-conversation') - } + }, }, } </script> diff --git a/src/components/LeftSidebar/LeftSidebar.vue b/src/components/LeftSidebar/LeftSidebar.vue index ae84d3219..c7bd30067 100644 --- a/src/components/LeftSidebar/LeftSidebar.vue +++ b/src/components/LeftSidebar/LeftSidebar.vue @@ -219,7 +219,7 @@ export default { // Reset the search text, therefore end the search operation. handleClickConversation() { this.searchText = '' - } + }, }, } </script> diff --git a/src/store/conversationsStore.js b/src/store/conversationsStore.js index 5b83ae8b5..697182166 100644 --- a/src/store/conversationsStore.js +++ b/src/store/conversationsStore.js @@ -20,7 +20,13 @@ * */ import Vue from 'vue' -import { makePublic, makePrivate, changeLobbyState } from '../services/conversationsService' +import { + makePublic, + makePrivate, + changeLobbyState, + addToFavorites, + removeFromFavorites, +} from '../services/conversationsService' import { getCurrentUser } from '@nextcloud/auth' import { CONVERSATION, WEBINAR } from '../constants' @@ -147,6 +153,22 @@ const actions = { commit('addConversation', conversation) }, + async toggleFavorite({ commit, getters }, { token, isFavorite }) { + const conversation = Object.assign({}, getters.conversations[token]) + if (!conversation) { + return + } + + if (isFavorite) { + await removeFromFavorites(token) + } else { + await addToFavorites(token) + } + conversation.isFavorite = !isFavorite + + commit('addConversation', conversation) + }, + async toggleLobby({ commit, getters }, { token, enableLobby }) { const conversation = Object.assign({}, getters.conversations[token]) if (!conversation) { |