Skip to content

Commit a9ea57e

Browse files
committed
Refactor default values for accessTokenState and activeTaskCategoryState
1 parent 79f8ea7 commit a9ea57e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/config/states.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ const userProfileState = atom<UserProfile | null>({
2929

3030
const accessTokenState = atom<string | null>({
3131
key: 'accessTokenState',
32-
default: (await get_access_token()).access_token,
32+
default: get_access_token().then(value => value?.access_token ?? null).catch((err) => {
33+
console.error("accessTokenState error", err)
34+
return null
35+
})
3336
});
3437

3538
const taskObjectState = atom<Task>({
@@ -39,7 +42,10 @@ const taskObjectState = atom<Task>({
3942

4043
const activeTaskCategoryState = atom<number>({
4144
key: 'activeTaskCategoryState',
42-
default: await SettingsStore.get<number>(settings.storage.constants.last_active_category) ?? -1
45+
default: SettingsStore.get<number>(settings.storage.constants.last_active_category).then(value => value ?? -1).catch(err => {
46+
console.error("activeTaskCategoryState error", err)
47+
return -1
48+
})
4349
});
4450

4551
const activeCategoryTasksState = atom<task[]>({

0 commit comments

Comments
 (0)