Skip to content

Commit

Permalink
Refactor default values for accessTokenState and activeTaskCategoryState
Browse files Browse the repository at this point in the history
  • Loading branch information
codad5 committed Apr 2, 2024
1 parent 79f8ea7 commit a9ea57e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/config/states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ const userProfileState = atom<UserProfile | null>({

const accessTokenState = atom<string | null>({
key: 'accessTokenState',
default: (await get_access_token()).access_token,
default: get_access_token().then(value => value?.access_token ?? null).catch((err) => {
console.error("accessTokenState error", err)
return null
})
});

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

const activeTaskCategoryState = atom<number>({
key: 'activeTaskCategoryState',
default: await SettingsStore.get<number>(settings.storage.constants.last_active_category) ?? -1
default: SettingsStore.get<number>(settings.storage.constants.last_active_category).then(value => value ?? -1).catch(err => {
console.error("activeTaskCategoryState error", err)
return -1
})
});

const activeCategoryTasksState = atom<task[]>({
Expand Down

0 comments on commit a9ea57e

Please sign in to comment.