Skip to content

Commit 9eb2780

Browse files
authored
refactor(client): switch settings.watch to settings.peek where reactivity is dead (RocketChat#40494)
1 parent 737443b commit 9eb2780

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

apps/meteor/client/lib/rooms/roomTypes/direct.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ roomCoordinator.add(
3535
case RoomSettingsEnum.JOIN_CODE:
3636
return false;
3737
case RoomSettingsEnum.E2E:
38-
return settings.watch('E2E_Enable') === true;
38+
return settings.peek('E2E_Enable') === true;
3939
default:
4040
return true;
4141
}
@@ -73,7 +73,7 @@ roomCoordinator.add(
7373
return;
7474
}
7575

76-
if (settings.watch('UI_Use_Real_Name') && subscription.fname) {
76+
if (settings.peek('UI_Use_Real_Name') && subscription.fname) {
7777
return subscription.fname;
7878
}
7979

apps/meteor/client/lib/rooms/roomTypes/private.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ roomCoordinator.add(
3232
case RoomSettingsEnum.REACT_WHEN_READ_ONLY:
3333
return Boolean(!room.broadcast && room.ro);
3434
case RoomSettingsEnum.E2E:
35-
return settings.watch('E2E_Enable') === true;
35+
return settings.peek('E2E_Enable') === true;
3636
case RoomSettingsEnum.SYSTEM_MESSAGES:
3737
default:
3838
return true;
@@ -55,7 +55,7 @@ roomCoordinator.add(
5555
if (roomData.prid || isRoomFederated(roomData)) {
5656
return roomData.fname;
5757
}
58-
if (settings.watch('UI_Allow_room_names_with_special_chars')) {
58+
if (settings.peek('UI_Allow_room_names_with_special_chars')) {
5959
return roomData.fname || roomData.name;
6060
}
6161

apps/meteor/client/lib/rooms/roomTypes/public.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ roomCoordinator.add(
5353
if (roomData.prid || isRoomFederated(roomData)) {
5454
return roomData.fname;
5555
}
56-
if (settings.watch('UI_Allow_room_names_with_special_chars')) {
56+
if (settings.peek('UI_Allow_room_names_with_special_chars')) {
5757
return roomData.fname || roomData.name;
5858
}
5959
return roomData.name;

apps/meteor/client/views/account/sidebarItems.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const {
1414
href: '/account/profile',
1515
i18nLabel: 'Profile',
1616
icon: 'user',
17-
permissionGranted: (): boolean => settings.watch('Accounts_AllowUserProfileChange') ?? true,
17+
permissionGranted: (): boolean => settings.peek('Accounts_AllowUserProfileChange') ?? true,
1818
},
1919
{
2020
href: '/account/preferences',
@@ -26,15 +26,15 @@ export const {
2626
i18nLabel: 'Security',
2727
icon: 'lock',
2828
permissionGranted: (): boolean =>
29-
(settings.watch('Accounts_TwoFactorAuthentication_Enabled') ?? true) ||
30-
(settings.watch('E2E_Enable') ?? false) ||
31-
(settings.watch('Accounts_AllowPasswordChange') ?? true),
29+
(settings.peek('Accounts_TwoFactorAuthentication_Enabled') ?? true) ||
30+
(settings.peek('E2E_Enable') ?? false) ||
31+
(settings.peek('Accounts_AllowPasswordChange') ?? true),
3232
},
3333
{
3434
href: '/account/integrations',
3535
i18nLabel: 'Integrations',
3636
icon: 'code',
37-
permissionGranted: (): boolean => settings.watch('Webdav_Integration_Enabled') ?? false,
37+
permissionGranted: (): boolean => settings.peek('Webdav_Integration_Enabled') ?? false,
3838
},
3939
{
4040
href: '/account/tokens',
@@ -53,7 +53,7 @@ export const {
5353
i18nLabel: 'Feature_preview',
5454
icon: 'flask',
5555
badge: () => <FeaturePreviewBadge />,
56-
permissionGranted: () => settings.watch('Accounts_AllowFeaturePreview') && defaultFeaturesPreview?.length > 0,
56+
permissionGranted: () => settings.peek('Accounts_AllowFeaturePreview') && defaultFeaturesPreview?.length > 0,
5757
},
5858
{
5959
href: '/account/accessibility-and-appearance',

0 commit comments

Comments
 (0)