@janiscommerce/app-tracking-shift 1.4.0-beta.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/Shift.js
CHANGED
|
@@ -6,13 +6,13 @@ import errorParser from '../../utils/errorParser';
|
|
|
6
6
|
export const useStorageValue = (key, defaultValue = null) => {
|
|
7
7
|
const readValue = useCallback(() => {
|
|
8
8
|
try {
|
|
9
|
-
return Storage.get(key)
|
|
9
|
+
return Storage.get(key) ?? defaultValue;
|
|
10
10
|
} catch (error) {
|
|
11
11
|
const parsedError = errorParser(error);
|
|
12
12
|
Crashlytics.recordError(parsedError, `[useStorageValue] Error with key: ${key}`);
|
|
13
13
|
return defaultValue;
|
|
14
14
|
}
|
|
15
|
-
}, [key]);
|
|
15
|
+
}, [key, defaultValue]);
|
|
16
16
|
|
|
17
17
|
const [value, setValue] = useState(readValue);
|
|
18
18
|
|
|
@@ -16,12 +16,12 @@ import errorParser from '../../errorParser';
|
|
|
16
16
|
const getWorkLogTypesData = () => {
|
|
17
17
|
try {
|
|
18
18
|
Crashlytics.log('getWorkLogTypesData');
|
|
19
|
-
const {workLogTypes = [], expirationTime = 0} = Storage.get(WORKLOG_TYPES_DATA);
|
|
19
|
+
const {workLogTypes = [], expirationTime = 0} = Storage.get(WORKLOG_TYPES_DATA) || {};
|
|
20
20
|
|
|
21
21
|
return {
|
|
22
22
|
workLogTypes,
|
|
23
23
|
expirationTime,
|
|
24
|
-
isExpired: expirationTime <= Date.now() || !workLogTypes
|
|
24
|
+
isExpired: expirationTime <= Date.now() || !workLogTypes?.length,
|
|
25
25
|
};
|
|
26
26
|
} catch (error) {
|
|
27
27
|
const parsedError = errorParser(error);
|