Skip to content

Commit 9f38b54

Browse files
fix(ui): Room mention click error without visual feedback (RocketChat#39985)
Co-authored-by: Douglas Fabris <devfabris@gmail.com>
1 parent 31d3419 commit 9f38b54

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.changeset/tidy-pillows-eat.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@rocket.chat/i18n': patch
3+
'@rocket.chat/meteor': patch
4+
---
5+
6+
Adds error feedback when clicking on a mentioned room you don't have access to

apps/meteor/client/views/room/hooks/useGoToRoom.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { IRoom, ISubscription } from '@rocket.chat/core-typings';
22
import { useStableCallback } from '@rocket.chat/fuselage-hooks';
3-
import { useMethod, useRouter } from '@rocket.chat/ui-contexts';
3+
import { useMethod, useRouter, useToastMessageDispatch } from '@rocket.chat/ui-contexts';
44

55
import { roomCoordinator } from '../../../lib/rooms/roomCoordinator';
66
import { Subscriptions } from '../../../stores';
@@ -13,6 +13,7 @@ type GoToRoomByIdOptions = {
1313
export const useGoToRoom = (): ((roomId: IRoom['_id'], options?: GoToRoomByIdOptions) => Promise<void>) => {
1414
const router = useRouter();
1515
const getRoomById = useMethod('getRoomById');
16+
const dispatchToastMessage = useToastMessageDispatch();
1617

1718
// TODO: remove params recycling
1819
return useStableCallback(async (roomId: IRoom['_id'], options?: GoToRoomByIdOptions) => {
@@ -25,7 +26,11 @@ export const useGoToRoom = (): ((roomId: IRoom['_id'], options?: GoToRoomByIdOpt
2526
return;
2627
}
2728

28-
const room = await getRoomById(roomId);
29-
roomCoordinator.openRouteLink(room.t, { rid: room._id, ...room }, router.getSearchParameters(), options);
29+
try {
30+
const room = await getRoomById(roomId);
31+
roomCoordinator.openRouteLink(room.t, { rid: room._id, ...room }, router.getSearchParameters(), options);
32+
} catch (error) {
33+
dispatchToastMessage({ type: 'error', message: error });
34+
}
3035
});
3136
};

0 commit comments

Comments
 (0)