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:
// 1. Have an affinity for
// 2. Do not have a relationship with
await this.refreshUserAffinities();
const userAffinities: Record<string, any>[] = UserAffinitiesStore.getUserAffinities();
const relationships = RelationshipStore.getMutableRelationships();
const nonFriendAffinities = userAffinities.filter(a => !RelationshipStore.getRelationshipType(a.otherUserId));
nonFriendAffinities.forEach(a => {
relationships[a.otherUserId] = 5;
relationships.set(a.otherUserId, 5);
});
RelationshipStore.emitChange();

View file

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

View file

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