Merge branch 'dev' into modules-proxy-patches

This commit is contained in:
Nuckyz 2024-06-14 18:15:23 -03:00
commit 83b09a8073
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
4 changed files with 23 additions and 4 deletions

View file

@ -142,7 +142,15 @@ function makeShortcuts() {
guildId: { getter: () => Common.SelectedGuildStore.getGuildId(), preload: false },
me: { getter: () => Common.UserStore.getCurrentUser(), preload: false },
meId: { getter: () => Common.UserStore.getCurrentUser().id, preload: false },
messages: { getter: () => Common.MessageStore.getMessages(Common.SelectedChannelStore.getChannelId()), preload: false }
messages: { getter: () => Common.MessageStore.getMessages(Common.SelectedChannelStore.getChannelId()), preload: false },
Stores: {
getter: () => Object.fromEntries(
Common.Flux.Store.getAll()
.map(store => [store.getName(), store] as const)
.filter(([name]) => name.length > 1)
)
}
};
}

View file

@ -21,7 +21,7 @@ import { UserUtils } from "@webpack/common";
import settings from "./settings";
import { ChannelDelete, ChannelType, GuildDelete, RelationshipRemove, RelationshipType } from "./types";
import { deleteGroup, deleteGuild, getGroup, getGuild, notify } from "./utils";
import { deleteGroup, deleteGuild, getGroup, getGuild, GuildAvailabilityStore, notify } from "./utils";
let manuallyRemovedFriend: string | undefined;
let manuallyRemovedGuild: string | undefined;
@ -63,7 +63,7 @@ export async function onRelationshipRemove({ relationship: { type, id } }: Relat
export function onGuildDelete({ guild: { id, unavailable } }: GuildDelete) {
if (!settings.store.servers) return;
if (unavailable) return;
if (unavailable || GuildAvailabilityStore.isUnavailable(id)) return;
if (manuallyRemovedGuild === id) {
deleteGuild(id);

View file

@ -19,11 +19,20 @@
import { DataStore, Notices } from "@api/index";
import { showNotification } from "@api/Notifications";
import { getUniqueUsername, openUserProfile } from "@utils/discord";
import { findStoreLazy } from "@webpack";
import { ChannelStore, GuildMemberStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common";
import { FluxStore } from "@webpack/types";
import settings from "./settings";
import { ChannelType, RelationshipType, SimpleGroupChannel, SimpleGuild } from "./types";
export const GuildAvailabilityStore = findStoreLazy("GuildAvailabilityStore") as FluxStore & {
totalGuilds: number;
totalUnavailableGuilds: number;
unavailableGuilds: string[];
isUnavailable(guildId: string): boolean;
};
const guilds = new Map<string, SimpleGuild>();
const groups = new Map<string, SimpleGroupChannel>();
const friends = {
@ -59,7 +68,7 @@ export async function syncAndRunChecks() {
if (settings.store.servers && oldGuilds?.size) {
for (const [id, guild] of oldGuilds) {
if (!guilds.has(id))
if (!guilds.has(id) && !GuildAvailabilityStore.isUnavailable(id))
notify(`You are no longer in the server ${guild.name}.`, guild.iconURL);
}
}

View file

@ -39,6 +39,8 @@ export class FluxStore {
syncWith: GenericFunction;
waitFor: GenericFunction;
__getLocalVars(): Record<string, any>;
static getAll(): FluxStore[];
}
export class FluxEmitter {