2023-01-25 03:25:29 +01:00
/ *
* 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/>.
* /
2025-07-10 00:38:39 +02:00
import * as t from "@vencord/discord-types" ;
2025-06-27 21:36:31 +02:00
import { findByCodeLazy , findByPropsLazy , waitFor } from "@webpack" ;
2023-01-25 03:25:29 +01:00
2023-02-10 22:33:34 +01:00
import { waitForStore } from "./internal" ;
2023-01-25 03:25:29 +01:00
2023-02-10 22:33:34 +01:00
export const Flux : t.Flux = findByPropsLazy ( "connectStores" ) ;
2023-05-23 03:32:27 +02:00
export type GenericStore = t . FluxStore & Record < string , any > ;
2023-02-10 22:33:34 +01:00
2024-06-19 03:04:15 +02:00
export const DraftType = findByPropsLazy ( "ChannelMessage" , "SlashCommand" ) ;
2023-08-19 09:19:10 +10:00
2025-07-10 00:38:39 +02:00
export let MessageStore : Omit < t.MessageStore , "getMessages" > & GenericStore & {
2023-01-25 03:25:29 +01:00
getMessages ( chanId : string ) : any ;
} ;
2023-02-10 22:33:34 +01:00
2025-05-14 17:08:56 -03:00
// 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
2023-01-25 03:25:29 +01:00
export const PrivateChannelsStore = findByPropsLazy ( "openPrivateChannel" ) ;
2023-02-10 22:33:34 +01:00
export let PermissionStore : GenericStore ;
export let GuildChannelStore : GenericStore ;
export let ReadStateStore : GenericStore ;
export let PresenceStore : GenericStore ;
2024-03-12 20:18:44 -03:00
export let GuildStore : t.GuildStore ;
2025-06-27 21:36:31 +02:00
export let GuildRoleStore : t.GuildRoleStore ;
2025-07-10 00:38:39 +02:00
export let GuildMemberStore : t.GuildMemberStore ;
export let UserStore : t.UserStore ;
2025-07-10 16:38:27 -04:00
export let UserProfileStore : t.UserProfileStore ;
2025-07-10 00:38:39 +02:00
export let SelectedChannelStore : t.SelectedChannelStore ;
export let SelectedGuildStore : t.SelectedGuildStore ;
export let ChannelStore : t.ChannelStore ;
2025-06-17 21:58:12 +02:00
export let RelationshipStore : t.RelationshipStore ;
2023-01-25 03:25:29 +01:00
2023-05-17 12:38:15 +10:00
export let EmojiStore : t.EmojiStore ;
2024-09-02 06:51:29 +02:00
export let ThemeStore : t.ThemeStore ;
2023-02-10 22:33:34 +01:00
export let WindowStore : t.WindowStore ;
2023-08-19 09:19:10 +10:00
export let DraftStore : t.DraftStore ;
2023-02-10 22:33:34 +01:00
/ * *
2025-07-10 00:38:39 +02:00
* @see jsdoc of { @link t . useStateFromStores }
2023-02-10 22:33:34 +01:00
* /
2024-06-19 03:04:15 +02:00
export const useStateFromStores : t.useStateFromStores = findByCodeLazy ( "useStateFromStores" ) ;
2023-02-10 22:33:34 +01:00
2023-08-19 09:19:10 +10:00
waitForStore ( "DraftStore" , s = > DraftStore = s ) ;
2023-02-10 22:33:34 +01:00
waitForStore ( "UserStore" , s = > UserStore = s ) ;
2023-09-08 03:42:20 +02:00
waitForStore ( "UserProfileStore" , m = > UserProfileStore = m ) ;
2023-02-10 22:33:34 +01:00
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 ) ;
2023-05-17 12:38:15 +10:00
waitForStore ( "EmojiStore" , m = > EmojiStore = m ) ;
2025-05-14 17:08:56 -03:00
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 ( ) ;
} ) ;
2025-06-27 21:36:31 +02:00
// 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 ) ;