Skip to content

Commit

Permalink
Refactor userStore to resolve issues with created models
Browse files Browse the repository at this point in the history
  • Loading branch information
heisner-tillman committed Aug 30, 2023
1 parent c097c98 commit cc2aa0b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions client/src/stores/userStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ export const useUserStore = defineStore("userStore", () => {
loadPromise = getCurrentUser()
.then(async (user) => {
const historyStore = useHistoryStore();
currentUser.value = { ...user, isAnonymous: !user.email };
currentPreferences.value = user?.preferences ?? null;
if ('email' in user) {
currentUser.value = { ...user, isAnonymous: false };
currentPreferences.value = user.preferences;
}
else {
currentUser.value = { isAnonymous: true };
currentPreferences.value = null;
}
// TODO: This is a hack to get around the fact that the API returns a string
if (currentPreferences.value?.favorites) {
currentPreferences.value.favorites = JSON.parse(user?.preferences?.favorites ?? { tools: [] });
Expand Down

0 comments on commit cc2aa0b

Please sign in to comment.