diff --git a/apps/meteor/app/ui-message/client/messageBox/messageBoxFormatting.ts b/apps/meteor/app/ui-message/client/messageBox/messageBoxFormatting.ts index af58cbe8590b4..6a3862e490dd0 100644 --- a/apps/meteor/app/ui-message/client/messageBox/messageBoxFormatting.ts +++ b/apps/meteor/app/ui-message/client/messageBox/messageBoxFormatting.ts @@ -101,6 +101,6 @@ export const formattingButtons: ReadonlyArray = [ } }, link: 'https://khan.github.io/KaTeX/function-support.html', - condition: () => settings.watch('Katex_Enabled') ?? true, + condition: () => settings.peek('Katex_Enabled') ?? true, }, ] as const; diff --git a/apps/meteor/app/utils/client/getRoomAvatarURL.ts b/apps/meteor/app/utils/client/getRoomAvatarURL.ts index 5abf77faa59b1..b15588bed486c 100644 --- a/apps/meteor/app/utils/client/getRoomAvatarURL.ts +++ b/apps/meteor/app/utils/client/getRoomAvatarURL.ts @@ -4,7 +4,7 @@ import { getAvatarURL } from './getAvatarURL'; import { settings } from '../../../client/lib/settings'; export const getRoomAvatarURL = ({ roomId, cache = '' }: { roomId: IRoom['_id']; cache: IRoom['avatarETag'] }) => { - const externalSource = (settings.watch('Accounts_RoomAvatarExternalProviderUrl') || '').trim().replace(/\/$/, ''); + const externalSource = (settings.peek('Accounts_RoomAvatarExternalProviderUrl') || '').trim().replace(/\/$/, ''); if (externalSource && typeof externalSource === 'string') { return externalSource.replace('{roomId}', roomId); } diff --git a/apps/meteor/app/utils/client/getURL.ts b/apps/meteor/app/utils/client/getURL.ts index b427c7110ccef..0a292e6009589 100644 --- a/apps/meteor/app/utils/client/getURL.ts +++ b/apps/meteor/app/utils/client/getURL.ts @@ -14,8 +14,8 @@ export const getURL = function ( cloudDeepLinkUrl?: string, cacheKey?: boolean, ): string { - const cdnPrefix = settings.watch('CDN_PREFIX') || ''; - const siteUrl = settings.watch('Site_Url') || ''; + const cdnPrefix = settings.peek('CDN_PREFIX') || ''; + const siteUrl = settings.peek('Site_Url') || ''; if (cacheKey) { path += `${path.includes('?') ? '&' : '?'}cacheKey=${Info.version}`; diff --git a/apps/meteor/app/utils/client/lib/getUserPreference.ts b/apps/meteor/app/utils/client/lib/getUserPreference.ts index ac3aec3e0c5ac..0e523fad8d3e2 100644 --- a/apps/meteor/app/utils/client/lib/getUserPreference.ts +++ b/apps/meteor/app/utils/client/lib/getUserPreference.ts @@ -43,5 +43,5 @@ export function getUserPreference( defaultValue?: TValue, ): TValue { const user = typeof userIdOrUser === 'string' ? Users.state.get(userIdOrUser) : userIdOrUser; - return user?.settings?.preferences?.[key] ?? defaultValue ?? settings.watch(`Accounts_Default_User_Preferences_${key}`); + return user?.settings?.preferences?.[key] ?? defaultValue ?? settings.peek(`Accounts_Default_User_Preferences_${key}`); } diff --git a/apps/meteor/app/utils/client/restrictions.ts b/apps/meteor/app/utils/client/restrictions.ts index 4e55bb1a52b90..84a1db0272d8d 100644 --- a/apps/meteor/app/utils/client/restrictions.ts +++ b/apps/meteor/app/utils/client/restrictions.ts @@ -2,8 +2,8 @@ import { settings } from '../../../client/lib/settings'; import { fileUploadIsValidContentTypeFromSettings } from '../lib/restrictions'; export const fileUploadIsValidContentType = function (type: string | undefined, customWhiteList?: string): boolean { - const blackList = settings.watch('FileUpload_MediaTypeBlackList') ?? 'image/svg+xml'; - const whiteList = customWhiteList ?? settings.watch('FileUpload_MediaTypeWhiteList') ?? ''; + const blackList = settings.peek('FileUpload_MediaTypeBlackList') ?? 'image/svg+xml'; + const whiteList = customWhiteList ?? settings.peek('FileUpload_MediaTypeWhiteList') ?? ''; return fileUploadIsValidContentTypeFromSettings(type, whiteList, blackList); }; diff --git a/apps/meteor/client/lib/rooms/roomTypes/direct.ts b/apps/meteor/client/lib/rooms/roomTypes/direct.ts index c569ba47a055a..e3288968cb688 100644 --- a/apps/meteor/client/lib/rooms/roomTypes/direct.ts +++ b/apps/meteor/client/lib/rooms/roomTypes/direct.ts @@ -35,7 +35,7 @@ roomCoordinator.add( case RoomSettingsEnum.JOIN_CODE: return false; case RoomSettingsEnum.E2E: - return settings.watch('E2E_Enable') === true; + return settings.peek('E2E_Enable') === true; default: return true; } @@ -73,7 +73,7 @@ roomCoordinator.add( return; } - if (settings.watch('UI_Use_Real_Name') && subscription.fname) { + if (settings.peek('UI_Use_Real_Name') && subscription.fname) { return subscription.fname; } diff --git a/apps/meteor/client/lib/rooms/roomTypes/private.ts b/apps/meteor/client/lib/rooms/roomTypes/private.ts index 31b8fa7ca7f7b..8af650fd671b6 100644 --- a/apps/meteor/client/lib/rooms/roomTypes/private.ts +++ b/apps/meteor/client/lib/rooms/roomTypes/private.ts @@ -32,7 +32,7 @@ roomCoordinator.add( case RoomSettingsEnum.REACT_WHEN_READ_ONLY: return Boolean(!room.broadcast && room.ro); case RoomSettingsEnum.E2E: - return settings.watch('E2E_Enable') === true; + return settings.peek('E2E_Enable') === true; case RoomSettingsEnum.SYSTEM_MESSAGES: default: return true; @@ -55,7 +55,7 @@ roomCoordinator.add( if (roomData.prid || isRoomFederated(roomData)) { return roomData.fname; } - if (settings.watch('UI_Allow_room_names_with_special_chars')) { + if (settings.peek('UI_Allow_room_names_with_special_chars')) { return roomData.fname || roomData.name; } diff --git a/apps/meteor/client/lib/rooms/roomTypes/public.ts b/apps/meteor/client/lib/rooms/roomTypes/public.ts index 00a3006381356..87ebf636c5a10 100644 --- a/apps/meteor/client/lib/rooms/roomTypes/public.ts +++ b/apps/meteor/client/lib/rooms/roomTypes/public.ts @@ -53,7 +53,7 @@ roomCoordinator.add( if (roomData.prid || isRoomFederated(roomData)) { return roomData.fname; } - if (settings.watch('UI_Allow_room_names_with_special_chars')) { + if (settings.peek('UI_Allow_room_names_with_special_chars')) { return roomData.fname || roomData.name; } return roomData.name; diff --git a/apps/meteor/client/lib/settings/settings.ts b/apps/meteor/client/lib/settings/settings.ts index f0026eab41ec2..13363b39279ce 100644 --- a/apps/meteor/client/lib/settings/settings.ts +++ b/apps/meteor/client/lib/settings/settings.ts @@ -1,6 +1,5 @@ import type { SettingValue } from '@rocket.chat/core-typings'; -import { watch } from '../../meteor/watch'; import { PublicSettings } from '../../stores'; type SettingCallback = (key: string, value: SettingValue) => void; @@ -8,11 +7,6 @@ type SettingCallback = (key: string, value: SettingValue) => void; class Settings { private readonly store = PublicSettings.use; - /** Get a setting value Tracker-reactively */ - watch(_id: string): TValue | undefined { - return watch(this.store, (state) => state.get(_id)?.value) as TValue | undefined; - } - /** Get a setting value non-reactively */ peek(_id: string): TValue | undefined { return this.store.getState().get(_id)?.value as TValue | undefined; diff --git a/apps/meteor/client/views/account/sidebarItems.tsx b/apps/meteor/client/views/account/sidebarItems.tsx index c565adcbcad66..14b06bbf04b81 100644 --- a/apps/meteor/client/views/account/sidebarItems.tsx +++ b/apps/meteor/client/views/account/sidebarItems.tsx @@ -14,7 +14,7 @@ export const { href: '/account/profile', i18nLabel: 'Profile', icon: 'user', - permissionGranted: (): boolean => settings.watch('Accounts_AllowUserProfileChange') ?? true, + permissionGranted: (): boolean => settings.peek('Accounts_AllowUserProfileChange') ?? true, }, { href: '/account/preferences', @@ -26,15 +26,15 @@ export const { i18nLabel: 'Security', icon: 'lock', permissionGranted: (): boolean => - (settings.watch('Accounts_TwoFactorAuthentication_Enabled') ?? true) || - (settings.watch('E2E_Enable') ?? false) || - (settings.watch('Accounts_AllowPasswordChange') ?? true), + (settings.peek('Accounts_TwoFactorAuthentication_Enabled') ?? true) || + (settings.peek('E2E_Enable') ?? false) || + (settings.peek('Accounts_AllowPasswordChange') ?? true), }, { href: '/account/integrations', i18nLabel: 'Integrations', icon: 'code', - permissionGranted: (): boolean => settings.watch('Webdav_Integration_Enabled') ?? false, + permissionGranted: (): boolean => settings.peek('Webdav_Integration_Enabled') ?? false, }, { href: '/account/tokens', @@ -53,7 +53,7 @@ export const { i18nLabel: 'Feature_preview', icon: 'flask', badge: () => , - permissionGranted: () => settings.watch('Accounts_AllowFeaturePreview') && defaultFeaturesPreview?.length > 0, + permissionGranted: () => settings.peek('Accounts_AllowFeaturePreview') && defaultFeaturesPreview?.length > 0, }, { href: '/account/accessibility-and-appearance',