Fix ImplicitRelationships & RelationshipNotifier (#3539)

This commit is contained in:
Amia 2025-07-04 15:04:12 +02:00 committed by dorkbutt
parent bef4b01382
commit 0e75d8a42f
No known key found for this signature in database
3 changed files with 4 additions and 5 deletions

View file

@ -125,12 +125,11 @@ export default definePlugin({
// Implicit relationships are defined as users that you: // Implicit relationships are defined as users that you:
// 1. Have an affinity for // 1. Have an affinity for
// 2. Do not have a relationship with // 2. Do not have a relationship with
await this.refreshUserAffinities();
const userAffinities: Record<string, any>[] = UserAffinitiesStore.getUserAffinities(); const userAffinities: Record<string, any>[] = UserAffinitiesStore.getUserAffinities();
const relationships = RelationshipStore.getMutableRelationships(); const relationships = RelationshipStore.getMutableRelationships();
const nonFriendAffinities = userAffinities.filter(a => !RelationshipStore.getRelationshipType(a.otherUserId)); const nonFriendAffinities = userAffinities.filter(a => !RelationshipStore.getRelationshipType(a.otherUserId));
nonFriendAffinities.forEach(a => { nonFriendAffinities.forEach(a => {
relationships[a.otherUserId] = 5; relationships.set(a.otherUserId, 5);
}); });
RelationshipStore.emitChange(); RelationshipStore.emitChange();

View file

@ -173,8 +173,8 @@ export async function syncFriends() {
friends.requests = []; friends.requests = [];
const relationShips = RelationshipStore.getMutableRelationships(); const relationShips = RelationshipStore.getMutableRelationships();
for (const id in relationShips) { for (const [id, type] of relationShips) {
switch (relationShips[id]) { switch (type) {
case RelationshipType.FRIEND: case RelationshipType.FRIEND:
friends.friends.push(id); friends.friends.push(id);
break; break;

View file

@ -255,5 +255,5 @@ export class RelationshipStore extends FluxStore {
getSince(userId: string): string; getSince(userId: string): string;
/** @returns Format: [userId: Enum value from constants.RelationshipTypes] */ /** @returns Format: [userId: Enum value from constants.RelationshipTypes] */
getMutableRelationships(): Record<number, number>; getMutableRelationships(): Map<string, number>;
} }