forked from Tadrisino/MathApp_frontend
32 lines
732 B
TypeScript
32 lines
732 B
TypeScript
/** localStorage با try/catch؛ در حالتِ خصوصیِ مرورگر یا دسترسیِ مسدود throw نمیکند. */
|
|
export const store = {
|
|
get(key: string): string | null {
|
|
try {
|
|
return localStorage.getItem(key);
|
|
} catch {
|
|
return null;
|
|
}
|
|
},
|
|
set(key: string, value: string) {
|
|
try {
|
|
localStorage.setItem(key, value);
|
|
} catch {
|
|
/* نادیده */
|
|
}
|
|
},
|
|
remove(key: string) {
|
|
try {
|
|
localStorage.removeItem(key);
|
|
} catch {
|
|
/* نادیده */
|
|
}
|
|
},
|
|
};
|
|
|
|
export const KEYS = {
|
|
onboarded: 'tadrisino.onboarded',
|
|
conversationId: 'tadrisino.conversationId',
|
|
sound: 'tadrisino.sound',
|
|
referralCode: 'tadrisino.referralCode',
|
|
} as const;
|