Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: fetch user by username

johnnyjoy7a685d64350a
diff --git a/web/src/pages/UserProfile.tsx b/web/src/pages/UserProfile.tsx
index 10c9294cd..a845758e5 100644
--- a/web/src/pages/UserProfile.tsx
+++ b/web/src/pages/UserProfile.tsx
@@ -32,7 +32,7 @@ const UserProfile = () => {
}
userStore
- .getOrFetchUserByName(username)
+ .fetchUserByUsername(username)
.then((user) => {
setUser(user);
loadingState.setFinish();
diff --git a/web/src/store/v2/user.ts b/web/src/store/v2/user.ts
index d7aa72d9b..a2ceb76cf 100644
--- a/web/src/store/v2/user.ts
+++ b/web/src/store/v2/user.ts
@@ -40,6 +40,19 @@ const userStore = (() => {
return user;
};
+ const fetchUserByUsername = async (username: string) => {
+ const user = await userServiceClient.getUser({
+ name: username,
+ });
+ state.setPartial({
+ userMapByName: {
+ ...state.userMapByName,
+ [user.name]: user,
+ },
+ });
+ return user;
+ };
+
const getUserByName = (name: string) => {
return state.userMapByName[name];
};
@@ -128,6 +141,7 @@ const userStore = (() => {
return {
state,
getOrFetchUserByName,
+ fetchUserByUsername,
getUserByName,
fetchUsers,
updateUser,