Type The RelationshipStore & Fixes

This commit is contained in:
thororen1234 2025-06-17 00:25:03 -04:00
parent 522e2b5b8f
commit b835d07fb1
No known key found for this signature in database
6 changed files with 33 additions and 18 deletions

View file

@ -63,14 +63,6 @@ export default definePlugin({
replace: "return $1;" 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() { start() {

View file

@ -140,7 +140,7 @@ export default definePlugin({
// 2. Do not have a relationship with // 2. Do not have a relationship with
await this.refreshUserAffinities(); await this.refreshUserAffinities();
const userAffinities: Set<string> = UserAffinitiesStore.getUserAffinitiesUserIds(); const userAffinities: Set<string> = UserAffinitiesStore.getUserAffinitiesUserIds();
const relationships = RelationshipStore.getRelationships(); const relationships = RelationshipStore.getMutableRelationships();
const nonFriendAffinities = Array.from(userAffinities).filter( const nonFriendAffinities = Array.from(userAffinities).filter(
id => !RelationshipStore.getRelationshipType(id) id => !RelationshipStore.getRelationshipType(id)
); );

View file

@ -172,7 +172,7 @@ export async function syncFriends() {
friends.friends = []; friends.friends = [];
friends.requests = []; friends.requests = [];
const relationShips = RelationshipStore.getRelationships(); const relationShips = RelationshipStore.getMutableRelationships();
for (const id in relationShips) { for (const id in relationShips) {
switch (relationShips[id]) { switch (relationShips[id]) {
case RelationshipType.FRIEND: case RelationshipType.FRIEND:

View file

@ -255,12 +255,12 @@ function FriendsTab({ guild, setCount }: RelationshipProps) {
} }
function BlockedUsersTab({ 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); return UserList("blocked", guild, blockedIds, setCount);
} }
function IgnoredUserTab({ guild, setCount }: RelationshipProps) { 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); return UserList("ignored", guild, ignoredIds, setCount);
} }

View file

@ -47,12 +47,7 @@ export let SelectedGuildStore: t.FluxStore & Record<string, any>;
export let ChannelStore: Stores.ChannelStore & t.FluxStore; export let ChannelStore: Stores.ChannelStore & t.FluxStore;
export let TypingStore: GenericStore; export let TypingStore: GenericStore;
export let GuildMemberStore: Stores.GuildMemberStore & t.FluxStore; export let GuildMemberStore: Stores.GuildMemberStore & t.FluxStore;
export let RelationshipStore: Stores.RelationshipStore & t.FluxStore & { export let RelationshipStore: t.RelationshipStore;
/** Get the date (as a string) that the relationship was created */
getFriendCount(): number;
getSince(userId: string): string;
isIgnored(userId: string): boolean;
};
export let EmojiStore: t.EmojiStore; export let EmojiStore: t.EmojiStore;
export let StickersStore: t.StickersStore; export let StickersStore: t.StickersStore;

View file

@ -188,6 +188,34 @@ export class StickersStore extends FluxStore {
getStickersByGuildId(id: string): Sticker[] | undefined; 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<number, number>;
getVersion(): number;
isSpam(userId): boolean;
getRelationshipType(userId: string): number;
getNickname(userId: string): string;
getSince(userId: string): string;
getSinces(): Record<number, string>;
getFriendIDs(): string[];
getBlockedIDs(): string[];
getIgnoredIDs(): string[];
getBlockedOrIgnoredIDs(): string[];
}
export interface DraftObject { export interface DraftObject {
channelId: string; channelId: string;
timestamp: number; timestamp: number;