-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathlocalStorage.ts
More file actions
33 lines (27 loc) · 1017 Bytes
/
localStorage.ts
File metadata and controls
33 lines (27 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export const localStorageAvailable = typeof Storage !== 'undefined';
export enum LocalStorageKeys {
DisplayName = 'DisplayName',
Theme = 'AzureCommunicationUI_Theme'
}
/**
* Get display name from local storage.
*/
export const getDisplayNameFromLocalStorage = (): string | null =>
window.localStorage.getItem(LocalStorageKeys.DisplayName);
/**
* Save display name into local storage.
*/
export const saveDisplayNameToLocalStorage = (displayName: string): void =>
window.localStorage.setItem(LocalStorageKeys.DisplayName, displayName);
/**
* Get theme from local storage.
*/
export const getThemeFromLocalStorage = (scopeId: string): string | null =>
window.localStorage.getItem(LocalStorageKeys.Theme + '_' + scopeId);
/**
* Save theme into local storage.
*/
export const saveThemeToLocalStorage = (theme: string, scopeId: string): void =>
window.localStorage.setItem(LocalStorageKeys.Theme + '_' + scopeId, theme);