Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ export const formattingButtons: ReadonlyArray<FormattingButton> = [
}
},
link: 'https://khan.github.io/KaTeX/function-support.html',
condition: () => settings.watch('Katex_Enabled') ?? true,
condition: () => settings.peek('Katex_Enabled') ?? true,
},
] as const;
2 changes: 1 addition & 1 deletion apps/meteor/app/utils/client/getRoomAvatarURL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/utils/client/getURL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/utils/client/lib/getUserPreference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ export function getUserPreference<TValue>(
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}`);
}
4 changes: 2 additions & 2 deletions apps/meteor/app/utils/client/restrictions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>('FileUpload_MediaTypeBlackList') ?? 'image/svg+xml';
const whiteList = customWhiteList ?? settings.watch<string>('FileUpload_MediaTypeWhiteList') ?? '';
const blackList = settings.peek<string>('FileUpload_MediaTypeBlackList') ?? 'image/svg+xml';
const whiteList = customWhiteList ?? settings.peek<string>('FileUpload_MediaTypeWhiteList') ?? '';

return fileUploadIsValidContentTypeFromSettings(type, whiteList, blackList);
};
6 changes: 0 additions & 6 deletions apps/meteor/client/lib/settings/settings.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import type { SettingValue } from '@rocket.chat/core-typings';

import { watch } from '../../meteor/watch';
import { PublicSettings } from '../../stores';

type SettingCallback = (key: string, value: SettingValue) => void;

class Settings {
private readonly store = PublicSettings.use;

/** Get a setting value Tracker-reactively */
watch<TValue = any>(_id: string): TValue | undefined {
return watch(this.store, (state) => state.get(_id)?.value) as TValue | undefined;
}

/** Get a setting value non-reactively */
peek<TValue = any>(_id: string): TValue | undefined {
return this.store.getState().get(_id)?.value as TValue | undefined;
Expand Down
Loading