From 6004243f4711a2f8c0b2a9dde366224ca5ec299d Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 12 Aug 2026 15:56:31 +0300 Subject: [PATCH] fixes for user lists --- src/components/follow_card/follow_card.js | 2 +- src/components/user_profile/user_profile.js | 10 ++--- src/components/user_profile/user_profile.vue | 4 +- .../entity_normalizer.service.js | 3 ++ src/stores/users.js | 39 +++++++++++-------- 5 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/components/follow_card/follow_card.js b/src/components/follow_card/follow_card.js index 228d15776..9a8b8746f 100644 --- a/src/components/follow_card/follow_card.js +++ b/src/components/follow_card/follow_card.js @@ -21,7 +21,7 @@ const FollowCard = { return useUsersStore().currentUser }, relationship() { - return this.$store.getters.relationship(this.user.id) + return useUsersStore().relationships.get(this.user.id) }, }, } diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index 191b5c8eb..732401028 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -79,14 +79,12 @@ const UserProfile = { return useMergedConfigStore().mergedConfig.compactProfiles }, friends() { - return get(useUsersStore().findUser(this.userId), 'friendIds', []).map( - (id) => useUsersStore().findUser(id), - ) + return [...this.user.friendIds.keys()] + .map((id) => useUsersStore().findUser(id)) }, followers() { - return get(useUsersStore().findUser(this.userId), 'followerIds', []).map( - (id) => useUsersStore().findUser(id), - ) + return [...this.user.followerIds.keys()] + .map((id) => useUsersStore().findUser(id)) }, }, methods: { diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue index ca74de0d6..4e4c53ab5 100644 --- a/src/components/user_profile/user_profile.vue +++ b/src/components/user_profile/user_profile.vue @@ -44,7 +44,7 @@ />
{ output.privileges = [] + output.friendIds = new Set() + output.followerIds = new Set() + if (data.pleroma) { if (data.pleroma.settings_store) { output.storage = data.pleroma.settings_store['pleroma-fe'] diff --git a/src/stores/users.js b/src/stores/users.js index cf88bcd43..9969a9cc9 100644 --- a/src/stores/users.js +++ b/src/stores/users.js @@ -121,26 +121,26 @@ export const useUsersStore = defineStore('users', { this.currentUser = null this.lastLoginName = null }, - saveFriendIds({ id, friendIds }) { + saveFriendIds(id, friendIds) { const user = this.users.get(id) - user.friendIds = [...new Set([...(user.friendIds || []), ...friendIds])] + user.friendIds = new Set([...user.friendIds, ...friendIds]) }, - saveFollowerIds({ id, followerIds }) { + saveFollowerIds(id, followerIds) { const user = this.users.get(id) - user.followerIds = [...new Set([user.followerIds || [], ...followerIds])] + user.followerIds = new Set([...user.followerIds, ...followerIds]) }, // Because frontend doesn't have a reason to keep these stuff in memory // outside of viewing someones user profile. clearFriends(userId) { const user = this.users.get(userId) if (user) { - user.friendIds = [] + user.friendIds = new Set() } }, clearFollowers(userId) { const user = this.users.get(userId) if (user) { - user.followerIds = [] + user.followerIds = new Set() } }, addNewUsers(response) { @@ -154,13 +154,18 @@ export const useUsersStore = defineStore('users', { // implicit: if oldTimestamp is undefined this will still be false if (oldTimestamp > timestamp) return existing // not overwriting old data with new - const { relationship: unused0, ...old } = existing - const { relationship: unused1, ...neu } = user - const newUser = { ...old, ...neu } + // TODO: Optimize + const { relationship: oldRelationship, ...oldUser } = existing + const { relationship: newRelationship, ...neuUser } = user + + const relationship = { ...oldRelationship, ...newRelationship } + const newUser = { ...oldUser, ...neuUser, relationship } this.users.set(user.id, newUser) this.usersByName.set(user.screen_name.toLowerCase(), newUser) this.usersByURL.set(user.url.toLowerCase(), newUser) + this.relationships.set(user.id, newRelationship) + this.timestamps.set(newUser, timestamp) if (user.id === this.currentUser.id) { @@ -507,10 +512,10 @@ export const useUsersStore = defineStore('users', { id, maxId, credentials: useOAuthStore().token, - }).then(({ data: friends }) => { - this.addNewUsers(friends) - this.saveFriendIds({ id, friendIds: map(friends, 'id') }) - return friends + }).then((result) => { + this.addNewUsers(result) + this.saveFriendIds(id, map(result.data, 'id')) + return result.data }) }, fetchFollowers(id) { @@ -520,10 +525,10 @@ export const useUsersStore = defineStore('users', { id, maxId, credentials: useOAuthStore().token, - }).then(({ data: followers }) => { - this.addNewUsers(followers) - this.saveFollowerIds({ id, followerIds: map(followers, 'id') }) - return followers + }).then((result) => { + this.addNewUsers(result) + this.saveFollowerIds(id, map(result.data, 'id')) + return result.data }) }, subscribeUser(id) {