perf: user openai

This commit is contained in:
archer
2023-08-05 12:26:26 +08:00
parent 37a6293f5e
commit bb824ab35e
6 changed files with 23 additions and 20 deletions

View File

@@ -53,6 +53,7 @@ export const useUserStore = create<State>()(
});
},
async updateUserInfo(user: UserUpdateParams) {
const oldInfo = (get().userInfo ? { ...get().userInfo } : null) as UserType | null;
set((state) => {
if (!state.userInfo) return;
state.userInfo = {
@@ -60,7 +61,14 @@ export const useUserStore = create<State>()(
...user
};
});
await putUserInfo(user);
try {
await putUserInfo(user);
} catch (error) {
set((state) => {
state.userInfo = oldInfo;
});
return Promise.reject(error);
}
},
myApps: [],
myCollectionApps: [],