diff options
-rw-r--r-- | src/App.vue | 9 | ||||
-rw-r--r-- | src/FilesSidebarTabApp.vue | 4 | ||||
-rw-r--r-- | src/PublicShareAuthSidebar.vue | 9 | ||||
-rw-r--r-- | src/PublicShareSidebar.vue | 9 | ||||
-rw-r--r-- | src/components/MessagesList/MessagesGroup/Message/Message.vue | 7 | ||||
-rw-r--r-- | src/components/NewMessageForm/NewMessageForm.vue | 4 | ||||
-rw-r--r-- | src/store/conversationsStore.js | 6 | ||||
-rw-r--r-- | src/store/messagesStore.js | 8 |
8 files changed, 34 insertions, 22 deletions
diff --git a/src/App.vue b/src/App.vue index 12fc4cfb9..c0bf36da0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -49,7 +49,6 @@ import RightSidebar from './components/RightSidebar/RightSidebar' import { EventBus } from './services/EventBus' import BrowserStorage from './services/BrowserStorage' import { getCurrentUser } from '@nextcloud/auth' -import { fetchConversation } from './services/conversationsService' import { joinConversation, leaveConversationSync, @@ -420,13 +419,9 @@ export default { try { /** - * Fetches the conversations from the server and then adds them one by one - * to the store. + * Fetches a single conversation */ - const response = await fetchConversation(token) - - // this.$store.dispatch('purgeConversationsStore') - this.$store.dispatch('addConversation', response.data.ocs.data) + await this.$store.dispatch('fetchConversation', { token }) /** * Emits a global event that is used in App.vue to update the page title once the diff --git a/src/FilesSidebarTabApp.vue b/src/FilesSidebarTabApp.vue index 682be4317..3bda40ee1 100644 --- a/src/FilesSidebarTabApp.vue +++ b/src/FilesSidebarTabApp.vue @@ -52,7 +52,6 @@ import { EventBus } from './services/EventBus' import { getFileConversation } from './services/filesIntegrationServices' -import { fetchConversation } from './services/conversationsService' import { joinConversation, leaveConversation, @@ -262,8 +261,7 @@ export default { return } - const response = await fetchConversation(this.token) - this.$store.dispatch('addConversation', response.data.ocs.data) + await this.$store.dispatch('fetchConversation', { token: this.token }) }, /** diff --git a/src/PublicShareAuthSidebar.vue b/src/PublicShareAuthSidebar.vue index e30f9b70d..11dbfac2f 100644 --- a/src/PublicShareAuthSidebar.vue +++ b/src/PublicShareAuthSidebar.vue @@ -42,7 +42,6 @@ import CallView from './components/CallView/CallView' import ChatView from './components/ChatView' import { PARTICIPANT } from './constants' import { EventBus } from './services/EventBus' -import { fetchConversation } from './services/conversationsService' import { joinConversation, leaveConversationSync, @@ -165,15 +164,17 @@ export default { } try { - const response = await fetchConversation(this.token) - this.$store.dispatch('addConversation', response.data.ocs.data) + await this.$store.dispatch('fetchConversation', { token: this.token }) // Although the current participant is automatically added to // the participants store it must be explicitly set in the // actors store. if (!this.$store.getters.getUserId()) { + // Set the current actor/participant for guests + const conversation = this.$store.getters.conversation(this.token) + // Setting a guest only uses "sessionId" and "participantType". - this.$store.dispatch('setCurrentParticipant', response.data.ocs.data) + this.$store.dispatch('setCurrentParticipant', conversation) } } catch (exception) { window.clearInterval(this.fetchCurrentConversationIntervalId) diff --git a/src/PublicShareSidebar.vue b/src/PublicShareSidebar.vue index 451daf5df..2eb6683cf 100644 --- a/src/PublicShareSidebar.vue +++ b/src/PublicShareSidebar.vue @@ -50,7 +50,6 @@ import CallView from './components/CallView/CallView' import ChatView from './components/ChatView' import CallButton from './components/TopBar/CallButton' import { EventBus } from './services/EventBus' -import { fetchConversation } from './services/conversationsService' import { getPublicShareConversationData } from './services/filesIntegrationServices' import { joinConversation, @@ -201,15 +200,17 @@ export default { } try { - const response = await fetchConversation(this.token) - this.$store.dispatch('addConversation', response.data.ocs.data) + await this.$store.dispatch('fetchConversation', { token: this.token }) // Although the current participant is automatically added to // the participants store it must be explicitly set in the // actors store. if (!this.$store.getters.getUserId()) { + // Set the current actor/participant for guests + const conversation = this.$store.getters.conversation(this.token) + // Setting a guest only uses "sessionId" and "participantType". - this.$store.dispatch('setCurrentParticipant', response.data.ocs.data) + this.$store.dispatch('setCurrentParticipant', conversation) } } catch (exception) { window.clearInterval(this.fetchCurrentConversationIntervalId) diff --git a/src/components/MessagesList/MessagesGroup/Message/Message.vue b/src/components/MessagesList/MessagesGroup/Message/Message.vue index 3a63c7a46..b09b02559 100644 --- a/src/components/MessagesList/MessagesGroup/Message/Message.vue +++ b/src/components/MessagesList/MessagesGroup/Message/Message.vue @@ -712,13 +712,16 @@ export default { } }, - handleMarkAsUnread() { + async handleMarkAsUnread() { // update in backend + visually - this.$store.dispatch('updateLastReadMessage', { + await this.$store.dispatch('updateLastReadMessage', { token: this.token, id: this.previousMessageId, updateVisually: true, }) + + // reload conversation to update additional attributes that have computed values + await this.$store.dispatch('fetchConversation', { token: this.token }) }, }, } diff --git a/src/components/NewMessageForm/NewMessageForm.vue b/src/components/NewMessageForm/NewMessageForm.vue index faeb145a5..548740494 100644 --- a/src/components/NewMessageForm/NewMessageForm.vue +++ b/src/components/NewMessageForm/NewMessageForm.vue @@ -228,6 +228,10 @@ export default { watch: { disabled(newValue) { + // the menu is not always available + if (!this.$refs.uploadMenu) { + return + } this.$refs.uploadMenu.$refs.menuButton.disabled = newValue }, diff --git a/src/store/conversationsStore.js b/src/store/conversationsStore.js index c694fa6f4..aade72893 100644 --- a/src/store/conversationsStore.js +++ b/src/store/conversationsStore.js @@ -29,6 +29,7 @@ import { changeListable, addToFavorites, removeFromFavorites, + fetchConversation, setConversationName, setConversationDescription } from '../services/conversationsService' import { getCurrentUser } from '@nextcloud/auth' @@ -335,6 +336,11 @@ const actions = { commit('updateConversationLastReadMessage', { token, lastReadMessage }) }, + async fetchConversation({ dispatch }, { token }) { + const response = await fetchConversation(token) + dispatch('addConversation', response.data.ocs.data) + }, + changeNotificationLevel({ commit }, { token, notificationLevel }) { commit('changeNotificationLevel', { token, notificationLevel }) }, diff --git a/src/store/messagesStore.js b/src/store/messagesStore.js index 6d8564de8..8d49c6dc5 100644 --- a/src/store/messagesStore.js +++ b/src/store/messagesStore.js @@ -386,7 +386,7 @@ const actions = { * @param {bool} updateVisually whether to also update the marker visually in the UI; */ async updateLastReadMessage(context, { token, id = 0, updateVisually = false }) { - const conversation = Object.assign({}, context.getters.conversations[token]) + const conversation = context.getters.conversations[token] if (!conversation || conversation.lastReadMessage === id) { return } @@ -400,7 +400,11 @@ const actions = { if (updateVisually) { context.commit('setVisualLastReadMessageId', { token, id }) } - await updateLastReadMessage(token, id) + + if (context.getters.getUserId()) { + // only update on server side if there's an actual user, not guest + await updateLastReadMessage(token, id) + } }, } |