From dc89a11b06259a594ad36ad6589c3ec343310bbf Mon Sep 17 00:00:00 2001 From: MartinSchoeler Date: Fri, 7 Jun 2024 15:16:11 -0300 Subject: [PATCH 1/3] fix(Omnichannel): nonstop sound on current chats using continuous notifications --- .../ComposerOmnichannel/ComposerOmnichannelInquiry.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsx b/apps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsx index 0144a2c858df..9042448fdd8b 100644 --- a/apps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsx +++ b/apps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsx @@ -4,6 +4,7 @@ import { useQuery } from '@tanstack/react-query'; import type { ReactElement } from 'react'; import React from 'react'; +import { useChat } from '../../contexts/ChatContext'; import { useOmnichannelRoom } from '../../contexts/RoomContext'; export const ComposerOmnichannelInquiry = (): ReactElement => { @@ -16,6 +17,10 @@ export const ComposerOmnichannelInquiry = (): ReactElement => { roomId: room._id, }), ); + + // TODO REMOVE THIS ONCE WE MOVE AWAY FROM INQUIRES! + const chat = useChat(); + const takeInquiry = useMethod('livechat:takeInquiry'); const handleTakeInquiry = async (): Promise => { @@ -27,6 +32,8 @@ export const ComposerOmnichannelInquiry = (): ReactElement => { } try { await takeInquiry(result.data.inquiry._id, { clientAction: true }); + // TODO REMOVE THIS ONCE WE MOVE AWAY FROM INQUIRES! + chat?.readStateManager.attemptMarkAsRead(); } catch (error) { dispatchToastMessage({ type: 'error', message: error }); } From a5a5d514924092919328d626843b6e84a826ddb0 Mon Sep 17 00:00:00 2001 From: MartinSchoeler Date: Mon, 10 Jun 2024 09:50:44 -0300 Subject: [PATCH 2/3] fix reviews --- .../client/views/room/body/hooks/useUnreadMessages.ts | 6 ++++-- .../ComposerOmnichannel/ComposerOmnichannelInquiry.tsx | 6 ------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/apps/meteor/client/views/room/body/hooks/useUnreadMessages.ts b/apps/meteor/client/views/room/body/hooks/useUnreadMessages.ts index 5e74164b7882..343b9cb88a98 100644 --- a/apps/meteor/client/views/room/body/hooks/useUnreadMessages.ts +++ b/apps/meteor/client/views/room/body/hooks/useUnreadMessages.ts @@ -93,9 +93,11 @@ export const useHandleUnread = ( const debouncedReadMessageRead = useMemo( () => withDebouncing({ wait: 500 })(() => { - chat.readStateManager.attemptMarkAsRead(); + if (subscribed) { + chat.readStateManager.attemptMarkAsRead(); + } }), - [chat.readStateManager], + [chat.readStateManager, subscribed], ); useEffect( diff --git a/apps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsx b/apps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsx index 9042448fdd8b..ff20456afe3e 100644 --- a/apps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsx +++ b/apps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsx @@ -4,7 +4,6 @@ import { useQuery } from '@tanstack/react-query'; import type { ReactElement } from 'react'; import React from 'react'; -import { useChat } from '../../contexts/ChatContext'; import { useOmnichannelRoom } from '../../contexts/RoomContext'; export const ComposerOmnichannelInquiry = (): ReactElement => { @@ -18,9 +17,6 @@ export const ComposerOmnichannelInquiry = (): ReactElement => { }), ); - // TODO REMOVE THIS ONCE WE MOVE AWAY FROM INQUIRES! - const chat = useChat(); - const takeInquiry = useMethod('livechat:takeInquiry'); const handleTakeInquiry = async (): Promise => { @@ -32,8 +28,6 @@ export const ComposerOmnichannelInquiry = (): ReactElement => { } try { await takeInquiry(result.data.inquiry._id, { clientAction: true }); - // TODO REMOVE THIS ONCE WE MOVE AWAY FROM INQUIRES! - chat?.readStateManager.attemptMarkAsRead(); } catch (error) { dispatchToastMessage({ type: 'error', message: error }); } From 4fe5d1fa230c2b1a4aa9c7095189a67d369c896a Mon Sep 17 00:00:00 2001 From: Martin Schoeler Date: Mon, 10 Jun 2024 10:04:05 -0300 Subject: [PATCH 3/3] Create thin-suns-invent.md --- .changeset/thin-suns-invent.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/thin-suns-invent.md diff --git a/.changeset/thin-suns-invent.md b/.changeset/thin-suns-invent.md new file mode 100644 index 000000000000..945f44420797 --- /dev/null +++ b/.changeset/thin-suns-invent.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fixes issues causing nonstop sound notification when taking a chat from the `Current Chats` view