diff --git a/src/equicordplugins/equicordHelper/index.tsx b/src/equicordplugins/equicordHelper/index.tsx index 0fe811ad..08db2e99 100644 --- a/src/equicordplugins/equicordHelper/index.tsx +++ b/src/equicordplugins/equicordHelper/index.tsx @@ -63,14 +63,6 @@ export default definePlugin({ replace: "return $1;" } ] - }, - // Adds getRelationships Back To The RelationshipStore - { - find: "getRelationshipCount(){", - replacement: { - match: /(?<=getRelationshipCount\(\)\{.{0,25}\})(?=.*?getFriendIDs\(\)\{.{0,25}.keys\((\i)\))/, - replace: "getRelationships(){return $1}" - } } ], start() { diff --git a/src/plugins/implicitRelationships/index.ts b/src/plugins/implicitRelationships/index.ts index 9bd428e0..d332fc6c 100644 --- a/src/plugins/implicitRelationships/index.ts +++ b/src/plugins/implicitRelationships/index.ts @@ -140,7 +140,7 @@ export default definePlugin({ // 2. Do not have a relationship with await this.refreshUserAffinities(); const userAffinities: Set = UserAffinitiesStore.getUserAffinitiesUserIds(); - const relationships = RelationshipStore.getRelationships(); + const relationships = RelationshipStore.getMutableRelationships(); const nonFriendAffinities = Array.from(userAffinities).filter( id => !RelationshipStore.getRelationshipType(id) ); diff --git a/src/plugins/relationshipNotifier/utils.ts b/src/plugins/relationshipNotifier/utils.ts index 84e812a7..75cf2d3a 100644 --- a/src/plugins/relationshipNotifier/utils.ts +++ b/src/plugins/relationshipNotifier/utils.ts @@ -172,7 +172,7 @@ export async function syncFriends() { friends.friends = []; friends.requests = []; - const relationShips = RelationshipStore.getRelationships(); + const relationShips = RelationshipStore.getMutableRelationships(); for (const id in relationShips) { switch (relationShips[id]) { case RelationshipType.FRIEND: diff --git a/src/plugins/serverInfo/GuildInfoModal.tsx b/src/plugins/serverInfo/GuildInfoModal.tsx index 3acb96b8..40a0a1ab 100644 --- a/src/plugins/serverInfo/GuildInfoModal.tsx +++ b/src/plugins/serverInfo/GuildInfoModal.tsx @@ -255,12 +255,12 @@ function FriendsTab({ guild, setCount }: RelationshipProps) { } function BlockedUsersTab({ guild, setCount }: RelationshipProps) { - const blockedIds = Object.keys(RelationshipStore.getRelationships()).filter(id => RelationshipStore.isBlocked(id)); + const blockedIds = RelationshipStore.getBlockedIDs(); return UserList("blocked", guild, blockedIds, setCount); } function IgnoredUserTab({ guild, setCount }: RelationshipProps) { - const ignoredIds = Object.keys(RelationshipStore.getRelationships()).filter(id => RelationshipStore.isIgnored(id)); + const ignoredIds = RelationshipStore.getIgnoredIDs(); return UserList("ignored", guild, ignoredIds, setCount); } diff --git a/src/webpack/common/stores.ts b/src/webpack/common/stores.ts index 8fd93bde..b554f7ac 100644 --- a/src/webpack/common/stores.ts +++ b/src/webpack/common/stores.ts @@ -47,12 +47,7 @@ export let SelectedGuildStore: t.FluxStore & Record; export let ChannelStore: Stores.ChannelStore & t.FluxStore; export let TypingStore: GenericStore; export let GuildMemberStore: Stores.GuildMemberStore & t.FluxStore; -export let RelationshipStore: Stores.RelationshipStore & t.FluxStore & { - /** Get the date (as a string) that the relationship was created */ - getFriendCount(): number; - getSince(userId: string): string; - isIgnored(userId: string): boolean; -}; +export let RelationshipStore: t.RelationshipStore; export let EmojiStore: t.EmojiStore; export let StickersStore: t.StickersStore; diff --git a/src/webpack/common/types/stores.d.ts b/src/webpack/common/types/stores.d.ts index c54811b0..9c7583e2 100644 --- a/src/webpack/common/types/stores.d.ts +++ b/src/webpack/common/types/stores.d.ts @@ -188,6 +188,34 @@ export class StickersStore extends FluxStore { getStickersByGuildId(id: string): Sticker[] | undefined; } +export class RelationshipStore extends RelationshipStore { + isFriend(userId: string): boolean; + isBlockedOrIgnored(userId: string): boolean; + isBlockedOrIgnoredForMessage(userId: string): boolean; + isBlocked(userId: string): boolean; + isBlockedForMessage(userId: string): boolean; + isIgnored(userId: string): boolean; + isIgnoredForMessage(userId: string): boolean; + isUnfilteredPendingIncoming(userId: string): boolean; + getPendingCount(): number; + getSpamCount(): number; + getPendingIgnoredCount(): number; + getOutgoingCount(): number; + getFriendCount(): number; + getRelationshipCount(): number; + getMutableRelationships(): Record; + getVersion(): number; + isSpam(userId): boolean; + getRelationshipType(userId: string): number; + getNickname(userId: string): string; + getSince(userId: string): string; + getSinces(): Record; + getFriendIDs(): string[]; + getBlockedIDs(): string[]; + getIgnoredIDs(): string[]; + getBlockedOrIgnoredIDs(): string[]; +} + export interface DraftObject { channelId: string; timestamp: number;