From 133967720057e9a11797ca7b52d40eba4e15cc3e Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Wed, 31 Jul 2024 17:40:06 +0200 Subject: [PATCH 1/3] fix(capabilities): correctly handle config-local -'config-local' is an array of string, whereas 'config' is an object with key-value pairs Signed-off-by: Maksim Sukharev --- src/services/CapabilitiesManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/CapabilitiesManager.ts b/src/services/CapabilitiesManager.ts index 471ac450e0c..23252c8057e 100644 --- a/src/services/CapabilitiesManager.ts +++ b/src/services/CapabilitiesManager.ts @@ -40,7 +40,7 @@ export function hasTalkFeature(token: string = 'local', feature: string): boolea * @param key2 second-level key (e.g. 'allowed') */ export function getTalkConfig(token: string = 'local', key1: keyof Config, key2: keyof Config[keyof Config]) { - if (localCapabilities?.spreed?.['config-local']?.[key1]?.[key2]) { + if (localCapabilities?.spreed?.['config-local']?.[key1]?.includes(key2)) { return localCapabilities?.spreed?.config?.[key1]?.[key2] } else if (token === 'local' || !remoteCapabilities[token]) { return localCapabilities?.spreed?.config?.[key1]?.[key2] From 3cafd5e75efdc2b3bd523710491791d7988f6703 Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Thu, 1 Aug 2024 20:03:36 +0200 Subject: [PATCH 2/3] fix(federation): mark Talk hash as dirty for federated rooms Signed-off-by: Maksim Sukharev --- src/services/CapabilitiesManager.ts | 5 +++++ src/stores/talkHash.js | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/services/CapabilitiesManager.ts b/src/services/CapabilitiesManager.ts index 23252c8057e..3324a607480 100644 --- a/src/services/CapabilitiesManager.ts +++ b/src/services/CapabilitiesManager.ts @@ -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'] @@ -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 diff --git a/src/stores/talkHash.js b/src/stores/talkHash.js index 430ba0b11f3..0fe18004a29 100644 --- a/src/stores/talkHash.js +++ b/src/stores/talkHash.js @@ -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' @@ -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. */ /** @@ -27,6 +29,7 @@ export const useTalkHashStore = defineStore('talkHash', { state: () => ({ initialNextcloudTalkHash: '', isNextcloudTalkHashDirty: false, + isNextcloudTalkProxyHashDirty: {}, maintenanceWarningToast: null, }), @@ -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 * From aa637f3cd4696af877571e58db9bac19ee37634f Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Thu, 1 Aug 2024 20:07:49 +0200 Subject: [PATCH 3/3] fix(federation): disable call button if proxy hash is dirty Signed-off-by: Maksim Sukharev --- src/components/TopBar/CallButton.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/TopBar/CallButton.vue b/src/components/TopBar/CallButton.vue index 70179c6b812..44d16217171 100644 --- a/src/components/TopBar/CallButton.vue +++ b/src/components/TopBar/CallButton.vue @@ -217,6 +217,7 @@ export default { }, isNextcloudTalkHashDirty() { return this.talkHashStore.isNextcloudTalkHashDirty + || this.talkHashStore.isNextcloudTalkProxyHashDirty[this.token] }, container() { return this.$store.getters.getMainContainerSelector()