1 import { createSelector } from '@reduxjs/toolkit';
3 import { type PassThemeOption } from '@proton/pass/components/Layout/Theme/types';
4 import { LockMode } from '@proton/pass/lib/auth/lock/types';
5 import { EXCLUDED_SETTINGS_KEYS } from '@proton/pass/store/reducers/settings';
6 import type { State } from '@proton/pass/store/types';
7 import type { Maybe } from '@proton/pass/types';
8 import type { DomainCriterias } from '@proton/pass/types/worker/settings';
9 import { pipe } from '@proton/pass/utils/fp/pipe';
10 import { omit } from '@proton/shared/lib/helpers/object';
12 import { selectState } from './utils';
14 export const selectProxiedSettings = createSelector(selectState, ({ settings }: State) =>
15 omit(settings, EXCLUDED_SETTINGS_KEYS)
18 export const selectCanLoadDomainImages = ({ settings }: State) => settings.loadDomainImages;
19 export const selectLockTTL = ({ settings }: State): Maybe<number> => settings.lockTTL;
20 export const selectDisallowedDomains = ({ settings }: State): DomainCriterias => settings.disallowedDomains;
21 export const selectLocale = ({ settings }: State) => settings.locale;
22 export const selectPasswordOptions = (state: State) => state.settings.passwordOptions;
23 export const selectAutosuggestCopyToClipboard = ({ settings }: State) => settings.autosuggest.passwordCopy;
24 export const selectCreatedItemsCount = ({ settings }: State) => settings.createdItemsCount;
25 export const selectOfflineEnabled = ({ settings }: State) => settings.offlineEnabled ?? false;
26 export const selectExtraPasswordEnabled = ({ settings }: State) => settings.extraPassword ?? false;
27 export const selectBetaEnabled = ({ settings }: State) => settings.beta ?? false;
28 export const selectLockMode = ({ settings }: State) => settings.lockMode ?? LockMode.NONE;
29 export const selectLockEnabled = pipe(selectLockMode, (mode) => mode !== LockMode.NONE);
30 export const selectShowUsernameField = ({ settings }: State) => settings.showUsernameField ?? false;
31 export const selectTheme = ({ settings }: State): Maybe<PassThemeOption> => settings?.theme;