1 import { type ProxiedSettings, getInitialSettings } from '@proton/pass/store/reducers/settings';
2 import type { MaybePromise } from '@proton/pass/types';
3 import { merge } from '@proton/pass/utils/object/merge';
5 export interface SettingsService {
6 clear: (localID?: number) => MaybePromise<void>;
7 resolve: (localID?: number) => Promise<ProxiedSettings>;
8 sync: (settings: ProxiedSettings, localID?: number) => MaybePromise<void>;
11 export const createSettingsService = (options: SettingsService): SettingsService => {
14 resolve: async (localID) => {
16 const settings = await options.resolve(localID);
17 return merge(getInitialSettings(), settings ?? {});
19 return getInitialSettings();