diff --git a/.changeset/tidy-pillows-eat.md b/.changeset/tidy-pillows-eat.md new file mode 100644 index 0000000000000..9f88cae17c924 --- /dev/null +++ b/.changeset/tidy-pillows-eat.md @@ -0,0 +1,6 @@ +--- +'@rocket.chat/i18n': patch +'@rocket.chat/meteor': patch +--- + +Adds error feedback when clicking on a mentioned room you don't have access to diff --git a/apps/meteor/client/views/room/hooks/useGoToRoom.ts b/apps/meteor/client/views/room/hooks/useGoToRoom.ts index d66d1d028f336..2c2569ab0bc01 100644 --- a/apps/meteor/client/views/room/hooks/useGoToRoom.ts +++ b/apps/meteor/client/views/room/hooks/useGoToRoom.ts @@ -1,6 +1,6 @@ import type { IRoom, ISubscription } from '@rocket.chat/core-typings'; import { useStableCallback } from '@rocket.chat/fuselage-hooks'; -import { useMethod, useRouter } from '@rocket.chat/ui-contexts'; +import { useMethod, useRouter, useToastMessageDispatch } from '@rocket.chat/ui-contexts'; import { roomCoordinator } from '../../../lib/rooms/roomCoordinator'; import { Subscriptions } from '../../../stores'; @@ -13,6 +13,7 @@ type GoToRoomByIdOptions = { export const useGoToRoom = (): ((roomId: IRoom['_id'], options?: GoToRoomByIdOptions) => Promise) => { const router = useRouter(); const getRoomById = useMethod('getRoomById'); + const dispatchToastMessage = useToastMessageDispatch(); // TODO: remove params recycling return useStableCallback(async (roomId: IRoom['_id'], options?: GoToRoomByIdOptions) => { @@ -25,7 +26,11 @@ export const useGoToRoom = (): ((roomId: IRoom['_id'], options?: GoToRoomByIdOpt return; } - const room = await getRoomById(roomId); - roomCoordinator.openRouteLink(room.t, { rid: room._id, ...room }, router.getSearchParameters(), options); + try { + const room = await getRoomById(roomId); + roomCoordinator.openRouteLink(room.t, { rid: room._id, ...room }, router.getSearchParameters(), options); + } catch (error) { + dispatchToastMessage({ type: 'error', message: error }); + } }); };