85 lines
3.6 KiB
TypeScript
85 lines
3.6 KiB
TypeScript
/*
|
|
* Vencord, a modification for Discord's desktop app
|
|
* Copyright (c) 2023 Vendicated and contributors
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
import * as t from "@vencord/discord-types";
|
|
import { findByCodeLazy, findByPropsLazy, waitFor } from "@webpack";
|
|
|
|
import { waitForStore } from "./internal";
|
|
|
|
export const Flux: t.Flux = findByPropsLazy("connectStores");
|
|
|
|
export type GenericStore = t.FluxStore & Record<string, any>;
|
|
|
|
export const DraftType = findByPropsLazy("ChannelMessage", "SlashCommand");
|
|
|
|
export let MessageStore: Omit<t.MessageStore, "getMessages"> & GenericStore & {
|
|
getMessages(chanId: string): any;
|
|
};
|
|
|
|
// TODO: The correct name for this is ChannelActionCreators and it has already been exported again from utils. Remove this export once enough time has passed
|
|
export const PrivateChannelsStore = findByPropsLazy("openPrivateChannel");
|
|
export let PermissionStore: GenericStore;
|
|
export let GuildChannelStore: GenericStore;
|
|
export let ReadStateStore: GenericStore;
|
|
export let PresenceStore: GenericStore;
|
|
|
|
export let GuildStore: t.GuildStore;
|
|
export let GuildRoleStore: t.GuildRoleStore;
|
|
export let GuildMemberStore: t.GuildMemberStore;
|
|
export let UserStore: t.UserStore;
|
|
export let UserProfileStore: t.UserProfileStore;
|
|
export let SelectedChannelStore: t.SelectedChannelStore;
|
|
export let SelectedGuildStore: t.SelectedGuildStore;
|
|
export let ChannelStore: t.ChannelStore;
|
|
export let RelationshipStore: t.RelationshipStore;
|
|
|
|
export let EmojiStore: t.EmojiStore;
|
|
export let ThemeStore: t.ThemeStore;
|
|
export let WindowStore: t.WindowStore;
|
|
export let DraftStore: t.DraftStore;
|
|
|
|
/**
|
|
* @see jsdoc of {@link t.useStateFromStores}
|
|
*/
|
|
export const useStateFromStores: t.useStateFromStores = findByCodeLazy("useStateFromStores");
|
|
|
|
waitForStore("DraftStore", s => DraftStore = s);
|
|
waitForStore("UserStore", s => UserStore = s);
|
|
waitForStore("UserProfileStore", m => UserProfileStore = m);
|
|
waitForStore("ChannelStore", m => ChannelStore = m);
|
|
waitForStore("SelectedChannelStore", m => SelectedChannelStore = m);
|
|
waitForStore("SelectedGuildStore", m => SelectedGuildStore = m);
|
|
waitForStore("GuildStore", m => GuildStore = m);
|
|
waitForStore("GuildMemberStore", m => GuildMemberStore = m);
|
|
waitForStore("RelationshipStore", m => RelationshipStore = m);
|
|
waitForStore("PermissionStore", m => PermissionStore = m);
|
|
waitForStore("PresenceStore", m => PresenceStore = m);
|
|
waitForStore("ReadStateStore", m => ReadStateStore = m);
|
|
waitForStore("GuildChannelStore", m => GuildChannelStore = m);
|
|
waitForStore("MessageStore", m => MessageStore = m);
|
|
waitForStore("WindowStore", m => WindowStore = m);
|
|
waitForStore("EmojiStore", m => EmojiStore = m);
|
|
waitForStore("ThemeStore", m => {
|
|
ThemeStore = m;
|
|
// Importing this directly can easily cause circular imports. For this reason, use a non import access here.
|
|
Vencord.QuickCss.initQuickCssThemeStore();
|
|
});
|
|
|
|
// GuildRoleStore is new, this code is for stable + canary compatibility
|
|
// TODO: Change to waitForStore once GuildRoleStore is on stable
|
|
waitFor(["getRole", "getRoles"], m => GuildRoleStore = m);
|