From a77052666ea9714eea92875fe01f607138dfe8f4 Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Fri, 26 Jan 2024 20:44:26 -0300 Subject: [PATCH] Rollback changes on streams --- .../hooks/webdav/useWebDAVAccountIntegrationsQuery.ts | 10 +--------- ee/packages/ddp-client/src/types/streams.ts | 6 ++---- packages/core-services/src/events/Events.ts | 6 +++--- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/apps/meteor/client/hooks/webdav/useWebDAVAccountIntegrationsQuery.ts b/apps/meteor/client/hooks/webdav/useWebDAVAccountIntegrationsQuery.ts index 3fc80f76e76c5..171490b33d18b 100644 --- a/apps/meteor/client/hooks/webdav/useWebDAVAccountIntegrationsQuery.ts +++ b/apps/meteor/client/hooks/webdav/useWebDAVAccountIntegrationsQuery.ts @@ -39,15 +39,7 @@ export const useWebDAVAccountIntegrationsQuery = ({ enabled = true, ...options } return subscribeToNotifyUser(`${uid}/webdav`, ({ type, account }) => { switch (type) { case 'changed': - queryClient.setQueryData(queryKey, (old = []) => { - const idx = old.findIndex((oldAccount) => oldAccount._id === account._id); - - if (idx === -1) { - return [...old, account]; - } - - return [...old.slice(0, idx), account, ...old.slice(idx + 1)]; - }); + queryClient.invalidateQueries(queryKey); break; case 'removed': diff --git a/ee/packages/ddp-client/src/types/streams.ts b/ee/packages/ddp-client/src/types/streams.ts index 257f3fdb43237..17638c2835128 100644 --- a/ee/packages/ddp-client/src/types/streams.ts +++ b/ee/packages/ddp-client/src/types/streams.ts @@ -24,7 +24,7 @@ import type { LicenseLimitKind, ICustomUserStatus, UserStatus, - IWebdavAccountIntegration, + IWebdavAccount, } from '@rocket.chat/core-typings'; import type * as UiKit from '@rocket.chat/ui-kit'; @@ -158,9 +158,7 @@ export interface StreamerEvents { { key: `${string}/force_logout`; args: [] }, { key: `${string}/webdav`; - args: [ - { type: 'changed'; account: IWebdavAccountIntegration } | { type: 'removed'; account: { _id: IWebdavAccountIntegration['_id'] } }, - ]; + args: [{ type: 'changed'; account: Partial } | { type: 'removed'; account: { _id: IWebdavAccount['_id'] } }]; }, { key: `${string}/e2ekeyRequest`; args: [string, string] }, { key: `${string}/notification`; args: [INotificationDesktop] }, diff --git a/packages/core-services/src/events/Events.ts b/packages/core-services/src/events/Events.ts index 666d6b85a1dc6..a592a777829cb 100644 --- a/packages/core-services/src/events/Events.ts +++ b/packages/core-services/src/events/Events.ts @@ -32,7 +32,7 @@ import type { ILivechatVisitor, LicenseLimitKind, ICustomUserStatus, - IWebdavAccountIntegration, + IWebdavAccount, } from '@rocket.chat/core-typings'; import type * as UiKit from '@rocket.chat/ui-kit'; @@ -84,11 +84,11 @@ export type EventSignatures = { data: | { type: 'changed'; - account: IWebdavAccountIntegration; + account: Partial; } | { type: 'removed'; - account: { _id: IWebdavAccountIntegration['_id'] }; + account: { _id: IWebdavAccount['_id'] }; }, ): void; 'notify.e2e.keyRequest'(rid: string, data: IRoom['e2eKeyId']): void;