Skip to content

Commit cb0ad21

Browse files
committed
fix: tests ^_^.
1 parent 23911a8 commit cb0ad21

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/lib/stores/preferences.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async function updateConsolePreferences(store: PreferencesStore): Promise<void>
3737
}
3838

3939
currentPreferences.console = {
40-
...(currentPreferences['console'] ?? {}),
40+
...(currentPreferences.console ?? {}),
4141
...store
4242
};
4343

@@ -50,13 +50,19 @@ function createPreferences() {
5050

5151
if (browser) {
5252
// fresh fetch.
53-
sdk.forConsole.account.getPrefs().then((userPreferences) => {
54-
if (!userPreferences?.console || Array.isArray(userPreferences.console)) {
55-
userPreferences.console = {};
56-
}
53+
sdk.forConsole.account
54+
.getPrefs()
55+
.then((userPreferences) => {
56+
if (!userPreferences?.console || Array.isArray(userPreferences.console)) {
57+
userPreferences.console = {};
58+
}
5759

58-
set(userPreferences.console);
59-
});
60+
set(userPreferences.console);
61+
})
62+
.catch(() => {
63+
// exception is thrown if there's no session; in that case - fallback!
64+
set(JSON.parse(globalThis.localStorage.getItem('preferences') ?? '{}'));
65+
});
6066
}
6167

6268
subscribe((v) => {

0 commit comments

Comments
 (0)