Skip to content

Commit

Permalink
fix(federation): mark Talk hash as dirty for federated rooms
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Aug 1, 2024
1 parent 1339677 commit 3cafd5e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/services/CapabilitiesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { t } from '@nextcloud/l10n'

import { getRemoteCapabilities } from './federationService.ts'
import BrowserStorage from '../services/BrowserStorage.js'
import { useTalkHashStore } from '../stores/talkHash.js'
import type { Capabilities, JoinRoomFullResponse } from '../types'

type Config = Capabilities['spreed']['config']
Expand Down Expand Up @@ -62,6 +63,10 @@ export async function setRemoteCapabilities(joinRoomResponse: JoinRoomFullRespon
return
}

// Mark the hash as dirty to prevent any activity in the conversation
const talkHashStore = useTalkHashStore()
talkHashStore.setTalkProxyHashDirty(token)

const response = await getRemoteCapabilities(token)
if (Array.isArray(response.data.ocs.data)) {
// unknown[] received from server, nothing to update with
Expand Down
19 changes: 16 additions & 3 deletions src/stores/talkHash.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { defineStore } from 'pinia'
import Vue from 'vue'

import { showError, TOAST_PERMANENT_TIMEOUT } from '@nextcloud/dialogs'
import { t } from '@nextcloud/l10n'
Expand All @@ -12,9 +13,10 @@ import { talkBroadcastChannel } from '../services/talkBroadcastChannel.js'

/**
* @typedef {object} State
* @property {string} initialNextcloudTalkHash - The absence status per conversation.
* @property {boolean} isNextcloudTalkHashDirty - The parent message id to reply per conversation.
* @property {object|null} maintenanceWarningToast -The input value per conversation.
* @property {string} initialNextcloudTalkHash - the 'default' Talk hash to compare with.
* @property {boolean} isNextcloudTalkHashDirty - whether Talk hash was updated and requires a reload.
* @property {object} isNextcloudTalkProxyHashDirty - whether Talk hash in federated conversation was updated.
* @property {object|null} maintenanceWarningToast - a toast object.
*/

/**
Expand All @@ -27,6 +29,7 @@ export const useTalkHashStore = defineStore('talkHash', {
state: () => ({
initialNextcloudTalkHash: '',
isNextcloudTalkHashDirty: false,
isNextcloudTalkProxyHashDirty: {},
maintenanceWarningToast: null,
}),

Expand All @@ -46,6 +49,16 @@ export const useTalkHashStore = defineStore('talkHash', {
}
},

/**
* Mark the current Talk Federation hash as dirty
*
* @param {string} token federated conversation token
*/
setTalkProxyHashDirty(token) {
console.debug('X-Nextcloud-Talk-Proxy-Hash marked dirty: ', token)
Vue.set(this.isNextcloudTalkProxyHashDirty, token, true)
},

/**
* Updates a Talk hash from a response
*
Expand Down

0 comments on commit 3cafd5e

Please sign in to comment.