()
| 26 | |
| 27 | /** Gets the current appearance state of the dev app. */ |
| 28 | export function getAppState(): DevAppState { |
| 29 | let value: DevAppState | null = null; |
| 30 | |
| 31 | // Needs a try/catch since some browsers throw an error when accessing in incognito. |
| 32 | try { |
| 33 | const storageValue = localStorage.getItem(KEY); |
| 34 | |
| 35 | if (storageValue) { |
| 36 | value = JSON.parse(storageValue); |
| 37 | } |
| 38 | } catch {} |
| 39 | |
| 40 | if (!value) { |
| 41 | value = { |
| 42 | density: 0, |
| 43 | animations: true, |
| 44 | zoneless: false, |
| 45 | darkTheme: false, |
| 46 | systemTheme: true, |
| 47 | rippleDisabled: false, |
| 48 | strongFocusEnabled: false, |
| 49 | m3Enabled: true, |
| 50 | direction: 'ltr', |
| 51 | colorApiBackCompat: true, |
| 52 | }; |
| 53 | |
| 54 | saveToStorage(value); |
| 55 | } |
| 56 | |
| 57 | return value; |
| 58 | } |
| 59 | |
| 60 | /** Saves the state of the dev app apperance in local storage. */ |
| 61 | export function setAppState(newState: DevAppState): void { |
no test coverage detected
searching dependent graphs…