From 76ed79c52c78229539ebb051120408aa3948d292 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Mon, 10 Feb 2025 22:47:46 +0700 Subject: [PATCH 1/5] UBERF-9455: Fix change of configurations and proper notifyTx (#7969) Signed-off-by: Andrey Sobolev --- packages/presentation/src/configuration.ts | 18 +++++----- packages/presentation/src/utils.ts | 9 ++--- .../ReverseChannelScrollView.svelte | 33 ++++++++++--------- plugins/devmodel-resources/src/index.ts | 2 +- .../src/components/Configure.svelte | 18 ++++++---- .../src/components/ActionHandler.svelte | 6 ++-- .../src/components/ActionsPopup.svelte | 14 ++++---- .../src/components/sidebar/Sidebar.svelte | 32 +++++++++--------- 8 files changed, 72 insertions(+), 60 deletions(-) diff --git a/packages/presentation/src/configuration.ts b/packages/presentation/src/configuration.ts index 6a71867cb2..9cee84e65f 100644 --- a/packages/presentation/src/configuration.ts +++ b/packages/presentation/src/configuration.ts @@ -13,7 +13,7 @@ // limitations under the License. // -import core, { SortingOrder, type PluginConfiguration, type TxUpdateDoc } from '@hcengineering/core' +import core, { SortingOrder, type PluginConfiguration, type Tx, type TxUpdateDoc } from '@hcengineering/core' import { getResourcePlugin, type Plugin, type Resource } from '@hcengineering/platform' import { writable } from 'svelte/store' import { addTxListener, createQuery } from '.' @@ -46,13 +46,15 @@ export const configurationStore = writable(configuration) const configQuery = createQuery(true) -addTxListener((tx) => { - if (tx._class === core.class.TxUpdateDoc) { - const cud = tx as TxUpdateDoc - if (cud.objectClass === core.class.PluginConfiguration) { - if (cud.operations.enabled !== undefined) { - // Plugin enabled/disabled we need to refresh - location.reload() +addTxListener((txes: Tx[]) => { + for (const tx of txes) { + if (tx._class === core.class.TxUpdateDoc) { + const cud = tx as TxUpdateDoc + if (cud.objectClass === core.class.PluginConfiguration) { + if (cud.operations.enabled !== undefined) { + // Plugin enabled/disabled we need to refresh + location.reload() + } } } } diff --git a/packages/presentation/src/utils.ts b/packages/presentation/src/utils.ts index dafc5333c1..087901f98f 100644 --- a/packages/presentation/src/utils.ts +++ b/packages/presentation/src/utils.ts @@ -67,12 +67,13 @@ let rawLiveQuery: LQ let client: TxOperations & Client let pipeline: PresentationPipeline -const txListeners: Array<(...tx: Tx[]) => void> = [] +export type TxListener = (tx: Tx[]) => void +const txListeners: TxListener[] = [] /** * @public */ -export function addTxListener (l: (tx: Tx) => void): void { +export function addTxListener (l: TxListener): void { txListeners.push(l) } @@ -83,7 +84,7 @@ export function getRawLiveQuery (): LQ { /** * @public */ -export function removeTxListener (l: (tx: Tx) => void): void { +export function removeTxListener (l: TxListener): void { const pos = txListeners.findIndex((it) => it === l) if (pos !== -1) { txListeners.splice(pos, 1) @@ -141,7 +142,7 @@ class UIClient extends TxOperations implements Client { await rawLiveQuery.tx(...tx) txListeners.forEach((it) => { - it(...tx) + it(tx) }) } catch (err: any) { Analytics.handleError(err) diff --git a/plugins/chunter-resources/src/components/ReverseChannelScrollView.svelte b/plugins/chunter-resources/src/components/ReverseChannelScrollView.svelte index 89908ba69e..15b4d0f4fc 100644 --- a/plugins/chunter-resources/src/components/ReverseChannelScrollView.svelte +++ b/plugins/chunter-resources/src/components/ReverseChannelScrollView.svelte @@ -13,25 +13,25 @@ // limitations under the License. --> diff --git a/plugins/view-resources/src/components/ActionHandler.svelte b/plugins/view-resources/src/components/ActionHandler.svelte index 859f018a4e..81a9f5479d 100644 --- a/plugins/view-resources/src/components/ActionHandler.svelte +++ b/plugins/view-resources/src/components/ActionHandler.svelte @@ -14,7 +14,7 @@ -->