Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { elemC } from 'Modules/array';
import { values } from 'Modules/record';
import { decode } from 'Modules/io';
import { getSyncStorage, setSyncStorage } from 'Modules/sync';
export enum Theme {
Light = 'light',
Dark = 'dark',
}
export const isTheme: Refinement = (arg): arg is Theme => pipe(
values(Theme),
elemC(eqString)(arg),
);
const themeCodec = fromRefinement(
'theme',
(x): x is Theme => t.string.is(x) && isTheme(x),
);
export enum BadgeDisplay {
WithCount = 'with_count',
WithoutCount = 'without_count',
None = 'none',
}
export const isBadgeDisplayOpt: Refinement = (arg): arg is BadgeDisplay => pipe(
values(BadgeDisplay),
elemC(eqString)(arg),
);
const badgeDisplayCodec = fromRefinement(
'theme',
(x): x is Theme => t.string.is(x) && isTheme(x),
);
export enum BadgeDisplay {
WithCount = 'with_count',
WithoutCount = 'without_count',
None = 'none',
}
export const isBadgeDisplayOpt: Refinement = (arg): arg is BadgeDisplay => pipe(
values(BadgeDisplay),
elemC(eqString)(arg),
);
const badgeDisplayCodec = fromRefinement(
'badgeDisplay',
(x): x is BadgeDisplay => t.string.is(x) && isBadgeDisplayOpt(x),
);
const settingsCodec = t.type({
theme: optionFromNullable(themeCodec),
badgeDisplay: optionFromNullable(badgeDisplayCodec),
});
export type Settings = t.TypeOf;
const theme = Lens.fromProp()('theme');
const badgeDisplay = Lens.fromProp()('badgeDisplay');
export const saveSettings = (opts: Settings): TaskEither => setSyncStorage(opts);