mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-28 07:54:22 -04:00
Type The RelationshipStore & Fixes
This commit is contained in:
parent
522e2b5b8f
commit
b835d07fb1
6 changed files with 33 additions and 18 deletions
|
@ -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() {
|
||||
|
|
|
@ -140,7 +140,7 @@ export default definePlugin({
|
|||
// 2. Do not have a relationship with
|
||||
await this.refreshUserAffinities();
|
||||
const userAffinities: Set<string> = UserAffinitiesStore.getUserAffinitiesUserIds();
|
||||
const relationships = RelationshipStore.getRelationships();
|
||||
const relationships = RelationshipStore.getMutableRelationships();
|
||||
const nonFriendAffinities = Array.from(userAffinities).filter(
|
||||
id => !RelationshipStore.getRelationshipType(id)
|
||||
);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,12 +47,7 @@ export let SelectedGuildStore: t.FluxStore & Record<string, any>;
|
|||
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;
|
||||
|
|
28
src/webpack/common/types/stores.d.ts
vendored
28
src/webpack/common/types/stores.d.ts
vendored
|
@ -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<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 {
|
||||
channelId: string;
|
||||
timestamp: number;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue