From 5cd1e975edbb29413e41057a4115e867a5d5c0bf Mon Sep 17 00:00:00 2001 From: yash-rajpal Date: Wed, 30 Oct 2024 03:10:01 +0530 Subject: [PATCH] fix query invalidation --- apps/meteor/client/startup/actionButtons/starMessage.ts | 3 ++- apps/meteor/client/startup/actionButtons/unstarMessage.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/meteor/client/startup/actionButtons/starMessage.ts b/apps/meteor/client/startup/actionButtons/starMessage.ts index 63287b6504ef..be4748436f5c 100644 --- a/apps/meteor/client/startup/actionButtons/starMessage.ts +++ b/apps/meteor/client/startup/actionButtons/starMessage.ts @@ -22,11 +22,12 @@ Meteor.startup(() => { try { await sdk.rest.post('/v1/chat.starMessage', { messageId: message._id }); starMessage(message, true); - queryClient.invalidateQueries(['rooms', message.rid, 'starred-messages']); } catch (error) { if (error) { dispatchToastMessage({ type: 'error', message: error }); } + } finally { + queryClient.invalidateQueries(['rooms', message.rid, 'starred-messages']); } }, condition({ message, subscription, user, room }) { diff --git a/apps/meteor/client/startup/actionButtons/unstarMessage.ts b/apps/meteor/client/startup/actionButtons/unstarMessage.ts index 283f2d84e222..5ba9029c20ea 100644 --- a/apps/meteor/client/startup/actionButtons/unstarMessage.ts +++ b/apps/meteor/client/startup/actionButtons/unstarMessage.ts @@ -21,9 +21,10 @@ Meteor.startup(() => { try { await sdk.rest.post('/v1/chat.unStarMessage', { messageId: message._id }); starMessage(message, false); - queryClient.invalidateQueries(['rooms', message.rid, 'starred-messages']); } catch (error) { dispatchToastMessage({ type: 'error', message: error }); + } finally { + queryClient.invalidateQueries(['rooms', message.rid, 'starred-messages']); } }, condition({ message, subscription, user }) {