Skip to content

Commit c6f77c0

Browse files
Fix in-context translation when no local storage settings (#1225)
Task: https://microbit-global.monday.com/boards/1125389526/pulses/2029300298 Fix settings default so that override is applied so that in-context translation works when no local storage setting is set.
1 parent bc195f3 commit c6f77c0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/common/use-storage.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export function useStorage<T extends object>(
2323
? localStorageIfPossible()
2424
: sessionStorageIfPossible();
2525
const value = storage ? storage.getItem(key) : null;
26+
const overiddenDefault = { ...defaultValue, ...overrides };
2627
if (value !== null) {
2728
try {
2829
let parsed = JSON.parse(value);
@@ -44,10 +45,10 @@ export function useStorage<T extends object>(
4445
return parsed;
4546
} catch (e) {
4647
// Better than exploding forever.
47-
return defaultValue;
48+
return overiddenDefault;
4849
}
4950
}
50-
return defaultValue;
51+
return overiddenDefault;
5152
});
5253
const setAndSaveState = useCallback(
5354
(value: T) => {

0 commit comments

Comments
 (0)