chore: fix user request cache

This commit is contained in:
Steven 2023-09-25 20:52:29 +08:00
parent 745902e8b1
commit 85ed0202d8

View file

@ -23,11 +23,13 @@ const useUserV1Store = create<UserV1Store>()((set, get) => ({
return await requestCache.get(username); return await requestCache.get(username);
} }
const promise = userServiceClient.getUser({ const promisedUser = userServiceClient
username: username, .getUser({
}); username: username,
requestCache.set(username, promise); })
const { user } = await promise; .then(({ user }) => user);
requestCache.set(username, promisedUser);
const user = await promisedUser;
if (!user) { if (!user) {
throw new Error("User not found"); throw new Error("User not found");
} }