1 | import { Platform } from '@unimodules/core';
|
2 | const LOCAL_STORAGE_KEY = 'EXPO_ERROR_RECOVERY_STORAGE';
|
3 |
|
4 | function _consumeRecoveryProps(): string | null {
|
5 | if (!Platform.isDOMAvailable) return null;
|
6 | try {
|
7 | const props = localStorage.getItem(LOCAL_STORAGE_KEY);
|
8 | localStorage.removeItem(LOCAL_STORAGE_KEY);
|
9 | return props;
|
10 | } catch (e) {
|
11 |
|
12 | }
|
13 | return null;
|
14 | }
|
15 |
|
16 | export default {
|
17 | get name(): string {
|
18 | return 'ExpoErrorRecovery';
|
19 | },
|
20 |
|
21 | saveRecoveryProps(props: string): void {
|
22 | if (!Platform.isDOMAvailable) return;
|
23 | try {
|
24 | localStorage.setItem(LOCAL_STORAGE_KEY, props);
|
25 | } catch (e) {
|
26 |
|
27 | }
|
28 | },
|
29 |
|
30 | recoveredProps: _consumeRecoveryProps(),
|
31 | };
|