1 import { differenceInDays } from 'date-fns';
3 import { getItem, setItem } from '@proton/shared/lib/helpers/storage';
4 import { ThemeModeSetting } from '@proton/shared/lib/themes/themes';
6 export const formatBooleanForHeartbeat = (setting: boolean | number | undefined) => {
7 if (setting === undefined) {
11 if (setting || setting === 1) {
18 export const getThemeMode = (mode?: ThemeModeSetting) => {
19 if (mode === undefined) {
24 case ThemeModeSetting.Auto:
26 case ThemeModeSetting.Dark:
28 case ThemeModeSetting.Light:
33 export const shouldSendHeartBeat = (settingKey: string) => {
34 const lastHeartBeatTimestamp = getItem(settingKey);
35 if (lastHeartBeatTimestamp) {
36 return differenceInDays(new Date(), new Date(lastHeartBeatTimestamp)) >= 7;
39 // If no last heartbeat, send a heartbeat immediately
43 export const saveHeartbeatTimestamp = (settingKey: string) => {
44 setItem(settingKey, new Date().getTime().toString());