Browse Source

Merge pull request #12557 from nextcloud/fix/12548/tabs-broadcast

fix(conversation): adjust broadcasted data between tabs
pull/12640/head
Maksim Sukharev 1 year ago
committed by GitHub
parent
commit
52cf4087e8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 28
      src/components/LeftSidebar/LeftSidebar.vue
  2. 3
      src/store/conversationsStore.js
  3. 2
      src/store/participantsStore.js

28
src/components/LeftSidebar/LeftSidebar.vue

@ -600,8 +600,10 @@ export default {
if (this.isCurrentTabLeader) {
switch (event.data.message) {
case 'force-fetch-all-conversations':
this.roomListModifiedBefore = 0
this.forceFullRoomListRefreshAfterXLoops = 10
if (event.data.options?.all) {
this.roomListModifiedBefore = 0
this.forceFullRoomListRefreshAfterXLoops = 10
}
this.debounceFetchConversations()
break
}
@ -612,6 +614,7 @@ export default {
conversations: event.data.conversations,
withRemoving: event.data.withRemoving,
})
this.federationStore.updatePendingSharesCount(event.data.invites)
break
case 'update-nextcloud-talk-hash':
this.talkHashStore.setNextcloudTalkHash(event.data.hash)
@ -839,23 +842,22 @@ export default {
* @param {boolean} [options.all] Whether all conversations should be fetched
*/
async handleShouldRefreshConversations(options) {
if (options?.all === true) {
if (this.isCurrentTabLeader) {
this.roomListModifiedBefore = 0
this.forceFullRoomListRefreshAfterXLoops = 10
} else {
// Force leader tab to do a full fetch
talkBroadcastChannel.postMessage({ message: 'force-fetch-all-conversations' })
return
}
} else if (options?.token && options?.properties) {
if (options?.token && options?.properties) {
await this.$store.dispatch('setConversationProperties', {
token: options.token,
properties: options.properties,
})
}
this.debounceFetchConversations()
if (this.isCurrentTabLeader) {
if (options?.all === true) {
this.roomListModifiedBefore = 0
this.forceFullRoomListRefreshAfterXLoops = 10
}
this.debounceFetchConversations()
} else {
talkBroadcastChannel.postMessage({ message: 'force-fetch-all-conversations', options })
}
},
async fetchConversations() {

3
src/store/conversationsStore.js

@ -441,7 +441,7 @@ const actions = {
await deleteConversation(token)
// upon success, also delete from store
await context.dispatch('deleteConversation', token)
talkBroadcastChannel.postMessage({ message: 'force-fetch-all-conversations' })
talkBroadcastChannel.postMessage({ message: 'force-fetch-all-conversations', options: { all: true } })
} catch (error) {
console.error('Error while deleting the conversation: ', error)
}
@ -878,6 +878,7 @@ const actions = {
talkBroadcastChannel.postMessage({
message: 'update-conversations',
conversations: response.data.ocs.data,
invites: response.headers['x-nextcloud-talk-federation-invites'],
withRemoving: modifiedSince === 0,
})
return response

2
src/store/participantsStore.js

@ -976,7 +976,7 @@ const actions = {
await removeCurrentUserFromConversation(token)
// If successful, deletes the conversation from the store
await context.dispatch('deleteConversation', token)
talkBroadcastChannel.postMessage({ message: 'force-fetch-all-conversations' })
talkBroadcastChannel.postMessage({ message: 'force-fetch-all-conversations', options: { all: true } })
},
/**

Loading…
Cancel
Save