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 Oct 17, 2023
1 parent 32da93e commit 29938fc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions client/src/stores/userStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ export const useUserStore = defineStore("userStore", () => {
if (!loadPromise) {
loadPromise = getCurrentUser()
.then(async (user) => {
currentUser.value = { ...user, isAnonymous: !user.email };
currentPreferences.value = user?.preferences ?? null;
const historyStore = useHistoryStore();
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 29938fc

Please sign in to comment.