From 2a50f263655541b972a49ad6eda638e5d44f05e8 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sat, 1 Aug 2026 23:04:13 -0400 Subject: [PATCH] Migrate All FindStoreLazy to src/webpack/common --- .../ApplicationStreamingSettingsStore.d.ts | 9 ++++ .../src/stores/AuthSessionsStore.d.ts | 9 ++++ .../src/stores/AuthorizedAppsStore.d.ts | 9 ++++ .../src/stores/ChannelMemberStore.d.ts | 14 +++++++ .../src/stores/ChannelSectionStore.d.ts | 6 +++ .../stores/ClientThemesBackgroundStore.d.ts | 5 +++ .../stores/CollapsedVoiceChannelStore.d.ts | 5 +++ .../src/stores/ConnectedAccountsStore.d.ts | 12 ++++++ .../src/stores/ExpandedGuildFolderStore.d.ts | 6 +++ .../src/stores/GuildAvailabilityStore.d.ts | 8 ++++ .../src/stores/JoinedThreadsStore.d.ts | 5 +++ .../src/stores/PrivateChannelSortStore.d.ts | 5 +++ .../src/stores/ReferencedMessageStore.d.ts | 5 +++ .../src/stores/SafetyHubStore.d.ts | 11 +++++ .../src/stores/SessionsStore.d.ts | 16 ++++++++ .../src/stores/SortedGuildStore.d.ts | 15 +++++++ .../src/stores/ThreadMemberListStore.d.ts | 10 +++++ .../src/stores/UserGuildJoinRequestStore.d.ts | 5 +++ .../src/stores/UserProfileSettingsStore.d.ts | 5 +++ packages/discord-types/src/stores/index.d.ts | 19 +++++++++ .../betterActivities/utils.tsx | 11 ++--- .../components/ChannelTabsContainer.tsx | 7 ++-- src/equicordplugins/equicordHelper/index.tsx | 5 +-- src/equicordplugins/followVoiceUser/index.tsx | 6 +-- .../hideServers/HiddenServersStore.ts | 5 +-- .../components/HiddenServersMenu.tsx | 4 +- src/equicordplugins/hideServers/index.tsx | 5 +-- src/equicordplugins/homeTyping/index.tsx | 5 +-- .../instantScreenshare/index.tsx | 5 +-- .../utils/contextMenu.tsx | 5 +-- .../messageLoggerEnhanced/utils/index.ts | 9 ++-- .../pingNotifications/index.tsx | 14 +++---- .../profileSets/utils/actions.ts | 7 +--- .../profileSets/utils/profile.ts | 6 +-- .../questify/utils/completion.ts | 3 +- .../questify/utils/fetching.ts | 3 +- src/equicordplugins/sidebarChat/index.tsx | 6 +-- .../unreadBadgeCount/index.tsx | 6 +-- src/equicordplugins/voiceButtons/utils.tsx | 5 +-- .../components/VoiceChannelLogModal.tsx | 5 +-- src/plugins/betterFolders/FolderSideBar.tsx | 10 ++--- src/plugins/betterFolders/index.tsx | 6 +-- src/plugins/betterSessions/index.tsx | 7 ++-- .../clientTheme/components/Settings.tsx | 7 ++-- src/plugins/gameActivityToggle/index.tsx | 16 +------- src/plugins/memberCount/MemberCount.tsx | 4 +- src/plugins/memberCount/index.tsx | 9 ---- src/plugins/noBlockedMessages/index.ts | 5 +-- src/plugins/pinDms/data.ts | 4 +- src/plugins/pinDms/index.tsx | 4 +- src/plugins/platformIndicators/index.tsx | 19 +-------- src/plugins/relationshipNotifier/functions.ts | 4 +- src/plugins/relationshipNotifier/utils.ts | 11 +---- src/plugins/serverListIndicators/index.tsx | 5 +-- src/plugins/showMeYourName/index.tsx | 6 +-- src/webpack/common/stores.ts | 41 +++++++++++++++++++ 56 files changed, 290 insertions(+), 169 deletions(-) create mode 100644 packages/discord-types/src/stores/ApplicationStreamingSettingsStore.d.ts create mode 100644 packages/discord-types/src/stores/AuthSessionsStore.d.ts create mode 100644 packages/discord-types/src/stores/AuthorizedAppsStore.d.ts create mode 100644 packages/discord-types/src/stores/ChannelMemberStore.d.ts create mode 100644 packages/discord-types/src/stores/ChannelSectionStore.d.ts create mode 100644 packages/discord-types/src/stores/ClientThemesBackgroundStore.d.ts create mode 100644 packages/discord-types/src/stores/CollapsedVoiceChannelStore.d.ts create mode 100644 packages/discord-types/src/stores/ConnectedAccountsStore.d.ts create mode 100644 packages/discord-types/src/stores/ExpandedGuildFolderStore.d.ts create mode 100644 packages/discord-types/src/stores/GuildAvailabilityStore.d.ts create mode 100644 packages/discord-types/src/stores/JoinedThreadsStore.d.ts create mode 100644 packages/discord-types/src/stores/PrivateChannelSortStore.d.ts create mode 100644 packages/discord-types/src/stores/ReferencedMessageStore.d.ts create mode 100644 packages/discord-types/src/stores/SafetyHubStore.d.ts create mode 100644 packages/discord-types/src/stores/SessionsStore.d.ts create mode 100644 packages/discord-types/src/stores/SortedGuildStore.d.ts create mode 100644 packages/discord-types/src/stores/ThreadMemberListStore.d.ts create mode 100644 packages/discord-types/src/stores/UserGuildJoinRequestStore.d.ts create mode 100644 packages/discord-types/src/stores/UserProfileSettingsStore.d.ts diff --git a/packages/discord-types/src/stores/ApplicationStreamingSettingsStore.d.ts b/packages/discord-types/src/stores/ApplicationStreamingSettingsStore.d.ts new file mode 100644 index 000000000..edb4e2d04 --- /dev/null +++ b/packages/discord-types/src/stores/ApplicationStreamingSettingsStore.d.ts @@ -0,0 +1,9 @@ +import { FluxStore } from ".."; + +export interface ApplicationStreamingSettingsState { + soundshareEnabled: boolean; +} + +export class ApplicationStreamingSettingsStore extends FluxStore { + getState(): ApplicationStreamingSettingsState; +} diff --git a/packages/discord-types/src/stores/AuthSessionsStore.d.ts b/packages/discord-types/src/stores/AuthSessionsStore.d.ts new file mode 100644 index 000000000..f7fa54f51 --- /dev/null +++ b/packages/discord-types/src/stores/AuthSessionsStore.d.ts @@ -0,0 +1,9 @@ +import { FluxStore } from ".."; + +export interface AuthSession { + id_hash: string; +} + +export class AuthSessionsStore extends FluxStore { + getSessions(): AuthSession[]; +} diff --git a/packages/discord-types/src/stores/AuthorizedAppsStore.d.ts b/packages/discord-types/src/stores/AuthorizedAppsStore.d.ts new file mode 100644 index 000000000..e01ffb395 --- /dev/null +++ b/packages/discord-types/src/stores/AuthorizedAppsStore.d.ts @@ -0,0 +1,9 @@ +import { FluxStore } from ".."; + +export interface AuthorizedAppToken { + id: string; +} + +export class AuthorizedAppsStore extends FluxStore { + getNewestTokenForApplication(applicationId: string): AuthorizedAppToken | undefined; +} diff --git a/packages/discord-types/src/stores/ChannelMemberStore.d.ts b/packages/discord-types/src/stores/ChannelMemberStore.d.ts new file mode 100644 index 000000000..a92e3e231 --- /dev/null +++ b/packages/discord-types/src/stores/ChannelMemberStore.d.ts @@ -0,0 +1,14 @@ +import { FluxStore } from ".."; + +export interface ChannelMemberGroup { + count: number; + id: string; +} + +export interface ChannelMemberProps { + groups: ChannelMemberGroup[]; +} + +export class ChannelMemberStore extends FluxStore { + getProps(guildId?: string, channelId?: string): ChannelMemberProps; +} diff --git a/packages/discord-types/src/stores/ChannelSectionStore.d.ts b/packages/discord-types/src/stores/ChannelSectionStore.d.ts new file mode 100644 index 000000000..490521360 --- /dev/null +++ b/packages/discord-types/src/stores/ChannelSectionStore.d.ts @@ -0,0 +1,6 @@ +import { FluxStore } from ".."; + +export class ChannelSectionStore extends FluxStore { + getGuildSidebarState(guildId?: string): unknown; + getSidebarState(channelId?: string): unknown; +} diff --git a/packages/discord-types/src/stores/ClientThemesBackgroundStore.d.ts b/packages/discord-types/src/stores/ClientThemesBackgroundStore.d.ts new file mode 100644 index 000000000..b5b7ae618 --- /dev/null +++ b/packages/discord-types/src/stores/ClientThemesBackgroundStore.d.ts @@ -0,0 +1,5 @@ +import { FluxStore } from ".."; + +export class ClientThemesBackgroundStore extends FluxStore { + gradientPreset: string | null; +} diff --git a/packages/discord-types/src/stores/CollapsedVoiceChannelStore.d.ts b/packages/discord-types/src/stores/CollapsedVoiceChannelStore.d.ts new file mode 100644 index 000000000..1533c45d7 --- /dev/null +++ b/packages/discord-types/src/stores/CollapsedVoiceChannelStore.d.ts @@ -0,0 +1,5 @@ +import { FluxStore } from ".."; + +export class CollapsedVoiceChannelStore extends FluxStore { + isCollapsed(channelId: string): boolean; +} diff --git a/packages/discord-types/src/stores/ConnectedAccountsStore.d.ts b/packages/discord-types/src/stores/ConnectedAccountsStore.d.ts new file mode 100644 index 000000000..f43a672f8 --- /dev/null +++ b/packages/discord-types/src/stores/ConnectedAccountsStore.d.ts @@ -0,0 +1,12 @@ +import { FluxStore } from ".."; + +export interface ConnectedAccount { + id: string; + type: string; + revoked: boolean; + showActivity: boolean; +} + +export class ConnectedAccountsStore extends FluxStore { + getAccounts(): ConnectedAccount[]; +} diff --git a/packages/discord-types/src/stores/ExpandedGuildFolderStore.d.ts b/packages/discord-types/src/stores/ExpandedGuildFolderStore.d.ts new file mode 100644 index 000000000..ab72002e8 --- /dev/null +++ b/packages/discord-types/src/stores/ExpandedGuildFolderStore.d.ts @@ -0,0 +1,6 @@ +import { FluxStore } from ".."; + +export class ExpandedGuildFolderStore extends FluxStore { + getExpandedFolders(): Set; + isFolderExpanded(folderId: number): boolean; +} diff --git a/packages/discord-types/src/stores/GuildAvailabilityStore.d.ts b/packages/discord-types/src/stores/GuildAvailabilityStore.d.ts new file mode 100644 index 000000000..9e5250c40 --- /dev/null +++ b/packages/discord-types/src/stores/GuildAvailabilityStore.d.ts @@ -0,0 +1,8 @@ +import { FluxStore } from ".."; + +export class GuildAvailabilityStore extends FluxStore { + totalGuilds: number; + totalUnavailableGuilds: number; + unavailableGuilds: string[]; + isUnavailable(guildId: string): boolean; +} diff --git a/packages/discord-types/src/stores/JoinedThreadsStore.d.ts b/packages/discord-types/src/stores/JoinedThreadsStore.d.ts new file mode 100644 index 000000000..3a306241a --- /dev/null +++ b/packages/discord-types/src/stores/JoinedThreadsStore.d.ts @@ -0,0 +1,5 @@ +import { FluxStore } from ".."; + +export class JoinedThreadsStore extends FluxStore { + isMuted(channelId: string): boolean; +} diff --git a/packages/discord-types/src/stores/PrivateChannelSortStore.d.ts b/packages/discord-types/src/stores/PrivateChannelSortStore.d.ts new file mode 100644 index 000000000..1883d5ea6 --- /dev/null +++ b/packages/discord-types/src/stores/PrivateChannelSortStore.d.ts @@ -0,0 +1,5 @@ +import { FluxStore } from ".."; + +export class PrivateChannelSortStore extends FluxStore { + getPrivateChannelIds(): string[]; +} diff --git a/packages/discord-types/src/stores/ReferencedMessageStore.d.ts b/packages/discord-types/src/stores/ReferencedMessageStore.d.ts new file mode 100644 index 000000000..2d054ec0b --- /dev/null +++ b/packages/discord-types/src/stores/ReferencedMessageStore.d.ts @@ -0,0 +1,5 @@ +import { FluxStore, Message } from ".."; + +export class ReferencedMessageStore extends FluxStore { + getMessageByReference(reference: Message["messageReference"]): { message: Message; } | undefined; +} diff --git a/packages/discord-types/src/stores/SafetyHubStore.d.ts b/packages/discord-types/src/stores/SafetyHubStore.d.ts new file mode 100644 index 000000000..a4de0d17c --- /dev/null +++ b/packages/discord-types/src/stores/SafetyHubStore.d.ts @@ -0,0 +1,11 @@ +import { FluxStore } from ".."; +import { StandingState } from "../../enums"; + +export interface AccountStanding { + state: StandingState; +} + +export class SafetyHubStore extends FluxStore { + getAccountStanding(): AccountStanding; + isInitialized(): boolean; +} diff --git a/packages/discord-types/src/stores/SessionsStore.d.ts b/packages/discord-types/src/stores/SessionsStore.d.ts new file mode 100644 index 000000000..b263625d4 --- /dev/null +++ b/packages/discord-types/src/stores/SessionsStore.d.ts @@ -0,0 +1,16 @@ +import { FluxStore } from ".."; + +export interface Session { + sessionId: string; + status: string; + active: boolean; + clientInfo: { + version: number; + os: string; + client: string; + }; +} + +export class SessionsStore extends FluxStore { + getSessions(): Record; +} diff --git a/packages/discord-types/src/stores/SortedGuildStore.d.ts b/packages/discord-types/src/stores/SortedGuildStore.d.ts new file mode 100644 index 000000000..876230ed2 --- /dev/null +++ b/packages/discord-types/src/stores/SortedGuildStore.d.ts @@ -0,0 +1,15 @@ +import { FluxStore } from ".."; + +export interface GuildFolder { + folderId: number | null; + folderName: string | null; + folderColor: number | null; + guildIds: string[]; + expanded?: boolean; +} + +export class SortedGuildStore extends FluxStore { + getFlattenedGuildIds(): string[]; + getGuildFolderById(folderId: number): GuildFolder; + getGuildFolders(): GuildFolder[]; +} diff --git a/packages/discord-types/src/stores/ThreadMemberListStore.d.ts b/packages/discord-types/src/stores/ThreadMemberListStore.d.ts new file mode 100644 index 000000000..c9bf4d1f0 --- /dev/null +++ b/packages/discord-types/src/stores/ThreadMemberListStore.d.ts @@ -0,0 +1,10 @@ +import { FluxStore } from ".."; + +export interface ThreadMemberListSection { + sectionId: string; + userIds: string[]; +} + +export class ThreadMemberListStore extends FluxStore { + getMemberListSections(channelId?: string): Record; +} diff --git a/packages/discord-types/src/stores/UserGuildJoinRequestStore.d.ts b/packages/discord-types/src/stores/UserGuildJoinRequestStore.d.ts new file mode 100644 index 000000000..4199320d6 --- /dev/null +++ b/packages/discord-types/src/stores/UserGuildJoinRequestStore.d.ts @@ -0,0 +1,5 @@ +import { FluxStore } from ".."; + +export class UserGuildJoinRequestStore extends FluxStore { + computeGuildIds(): string[]; +} diff --git a/packages/discord-types/src/stores/UserProfileSettingsStore.d.ts b/packages/discord-types/src/stores/UserProfileSettingsStore.d.ts new file mode 100644 index 000000000..2641d38fa --- /dev/null +++ b/packages/discord-types/src/stores/UserProfileSettingsStore.d.ts @@ -0,0 +1,5 @@ +import { FluxStore } from ".."; + +export class UserProfileSettingsStore extends FluxStore { + getPendingChanges(guildId?: string): Record; +} diff --git a/packages/discord-types/src/stores/index.d.ts b/packages/discord-types/src/stores/index.d.ts index 77c14eef0..0212f37df 100644 --- a/packages/discord-types/src/stores/index.d.ts +++ b/packages/discord-types/src/stores/index.d.ts @@ -3,18 +3,28 @@ export * from "./AccessibilityStore"; export * from "./ActiveJoinedThreadsStore"; export * from "./ApplicationCommandIndexStore"; export * from "./ApplicationStore"; +export * from "./ApplicationStreamingSettingsStore"; export * from "./ApplicationStreamingStore"; export * from "./ApplicationStreamPreviewStore"; export * from "./AuthenticationStore"; +export * from "./AuthorizedAppsStore"; +export * from "./AuthSessionsStore"; export * from "./CallStore"; +export * from "./ChannelMemberStore"; export * from "./ChannelRTCStore"; +export * from "./ChannelSectionStore"; export * from "./ChannelStore"; +export * from "./ClientThemesBackgroundStore"; +export * from "./CollapsedVoiceChannelStore"; +export * from "./ConnectedAccountsStore"; export * from "./DraftStore"; export * from "./EditMessageStore"; export * from "./EmojiStore"; +export * from "./ExpandedGuildFolderStore"; export * from "./ExperimentStore"; export * from "./FluxStore"; export * from "./FriendsStore"; +export * from "./GuildAvailabilityStore"; export * from "./GuildChannelStore"; export * from "./GuildMemberCountStore"; export * from "./GuildMemberStore"; @@ -23,6 +33,7 @@ export * from "./GuildScheduledEventStore"; export * from "./GuildStore"; export * from "./InstantInviteStore"; export * from "./InviteStore"; +export * from "./JoinedThreadsStore"; export * from "./LocaleStore"; export * from "./MediaEngineStore"; export * from "./MessageStore"; @@ -32,23 +43,31 @@ export * from "./PendingReplyStore"; export * from "./PermissionStore"; export * from "./PopoutWindowStore"; export * from "./PresenceStore"; +export * from "./PrivateChannelSortStore"; export * from "./QuestStore"; export * from "./ReadStateStore"; +export * from "./ReferencedMessageStore"; export * from "./RelationshipStore"; export * from "./RTCConnectionStore"; export * from "./RunningGameStore"; +export * from "./SafetyHubStore"; export * from "./SelectedChannelStore"; export * from "./SelectedGuildStore"; +export * from "./SessionsStore"; export * from "./SoundboardStore"; +export * from "./SortedGuildStore"; export * from "./SpellCheckStore"; export * from "./SpotifyStore"; export * from "./StickersStore"; export * from "./StreamerModeStore"; export * from "./ThemeStore"; +export * from "./ThreadMemberListStore"; export * from "./TypingStore"; export * from "./UploadAttachmentStore"; export * from "./UserAffinitiesStore"; +export * from "./UserGuildJoinRequestStore"; export * from "./UserGuildSettingsStore"; +export * from "./UserProfileSettingsStore"; export * from "./UserProfileStore"; export * from "./UserSettingsProtoStore"; export * from "./UserStore"; diff --git a/src/equicordplugins/betterActivities/utils.tsx b/src/equicordplugins/betterActivities/utils.tsx index 61fb0bf58..e9d131000 100644 --- a/src/equicordplugins/betterActivities/utils.tsx +++ b/src/equicordplugins/betterActivities/utils.tsx @@ -6,15 +6,12 @@ import { classNameFactory } from "@utils/css"; import { Activity, Application } from "@vencord/discord-types"; -import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; +import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; +import { ApplicationStore } from "@webpack/common"; import { settings } from "./settings"; import { ActivityViewProps, ApplicationIcon } from "./types"; -const ApplicationStore: { - getApplication: (id: string) => Application | null; -} = findStoreLazy("ApplicationStore"); - const { fetchApplication }: { fetchApplication: (id: string) => Promise; } = findByPropsLazy("fetchApplication"); @@ -33,7 +30,7 @@ export function getActivityApplication(activity: Activity | null) { if (!application_id) return undefined; let application = ApplicationStore.getApplication(application_id); if (!application && fetchedApplications.has(application_id)) { - application = fetchedApplications.get(application_id) ?? null; + application = fetchedApplications.get(application_id)!; } return application ?? undefined; } @@ -92,7 +89,7 @@ export function getApplicationIcons(activities: Activity[], preferSmall = false) let application = ApplicationStore.getApplication(application_id); if (!application) { if (fetchedApplications.has(application_id)) { - application = fetchedApplications.get(application_id) as Application | null; + application = fetchedApplications.get(application_id)!; } else { fetchedApplications.set(application_id, null); fetchApplication(application_id).then(app => { diff --git a/src/equicordplugins/channelTabs/components/ChannelTabsContainer.tsx b/src/equicordplugins/channelTabs/components/ChannelTabsContainer.tsx index 28bfdc937..bb7e1f429 100644 --- a/src/equicordplugins/channelTabs/components/ChannelTabsContainer.tsx +++ b/src/equicordplugins/channelTabs/components/ChannelTabsContainer.tsx @@ -11,8 +11,8 @@ import { BasicChannelTabsProps, ChannelTabsProps, clearStaleNavigationContext, c import { classNameFactory } from "@utils/css"; import { classes } from "@utils/misc"; import { useForceUpdater } from "@utils/react"; -import { findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { Button, ContextMenuApi, FluxDispatcher, useCallback, useEffect, useRef, UserStore, useState, useStateFromStores } from "@webpack/common"; +import { findComponentByCodeLazy } from "@webpack"; +import { Button, ChannelRTCStore, ContextMenuApi, FluxDispatcher, useCallback, useEffect, useRef, UserStore, useState, useStateFromStores } from "@webpack/common"; import channelTabs from ".."; import BookmarkContainer, { HorizontalScroller } from "./BookmarkContainer"; @@ -22,7 +22,6 @@ import { BasicContextMenu } from "./ContextMenus"; type TabSet = Record; const PlusSmallIcon = findComponentByCodeLazy("0v-5h5a1"); -const ChannelRTCStore = findStoreLazy("ChannelRTCStore"); const cl = classNameFactory("vc-channeltabs-"); @@ -97,7 +96,7 @@ export default function ChannelsTabsContainer(props: BasicChannelTabsProps) { "newTabButtonBehavior" ]); const GhostTabs = useGhostTabs(); - const isFullscreen = useStateFromStores([ChannelRTCStore], () => ChannelRTCStore.isFullscreenInContext() ?? false); + const isFullscreen = useStateFromStores([], () => ChannelRTCStore.isFullscreenInContext() ?? false); const _update = useForceUpdater(); const update = useCallback((save = true) => { diff --git a/src/equicordplugins/equicordHelper/index.tsx b/src/equicordplugins/equicordHelper/index.tsx index ba3d246bd..b1e03d8c5 100644 --- a/src/equicordplugins/equicordHelper/index.tsx +++ b/src/equicordplugins/equicordHelper/index.tsx @@ -15,8 +15,8 @@ import { Devs, EquicordDevs, GUILD_ID, SUPPORT_CHANNEL_ID, SUPPORT_CHANNEL_IDS, import { isAnyPluginDev } from "@utils/misc"; import definePlugin, { OptionType } from "@utils/types"; import { StandingState } from "@vencord/discord-types/enums"; -import { findByCodeLazy, findStoreLazy } from "@webpack"; -import { Alerts, ApplicationCommandIndexStore, NavigationRouter, React, SettingsRouter, UserGuildSettingsStore, UserStore, useStateFromStores, VoiceStateStore } from "@webpack/common"; +import { findByCodeLazy } from "@webpack"; +import { Alerts, ApplicationCommandIndexStore, NavigationRouter, React, SafetyHubStore, SettingsRouter, UserGuildSettingsStore, UserStore, useStateFromStores, VoiceStateStore } from "@webpack/common"; import { ComponentType } from "react"; import { PluginButtons } from "./pluginButtons"; @@ -28,7 +28,6 @@ migratePluginToSettings(true, "EquicordHelper", "GuildTagSettings", "disableAdop let clicked = false; -const SafetyHubStore = findStoreLazy("SafetyHubStore"); const fetchSafetyHub: () => Promise = findByCodeLazy("SAFETY_HUB_FETCH_START"); const StandingConfig: Record; }> = { diff --git a/src/equicordplugins/followVoiceUser/index.tsx b/src/equicordplugins/followVoiceUser/index.tsx index 56f242166..b8b2af846 100644 --- a/src/equicordplugins/followVoiceUser/index.tsx +++ b/src/equicordplugins/followVoiceUser/index.tsx @@ -10,8 +10,8 @@ import { Notice } from "@components/Notice"; import { EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { Channel, User, VoiceState } from "@vencord/discord-types"; -import { findByPropsLazy, findStoreLazy } from "@webpack"; -import { Menu, React, VoiceStateStore } from "@webpack/common"; +import { findByPropsLazy } from "@webpack"; +import { Menu, React, RelationshipStore, UserStore, VoiceStateStore } from "@webpack/common"; type TFollowedUserInfo = { lastChannelId: string; @@ -27,8 +27,6 @@ interface UserContextProps { let followedUserInfo: TFollowedUserInfo = null; const voiceChannelAction = findByPropsLazy("selectVoiceChannel"); -const UserStore = findStoreLazy("UserStore"); -const RelationshipStore = findStoreLazy("RelationshipStore"); const settings = definePluginSettings({ onlyWhenInVoice: { diff --git a/src/equicordplugins/hideServers/HiddenServersStore.ts b/src/equicordplugins/hideServers/HiddenServersStore.ts index 386ac25ad..fb0293ce3 100644 --- a/src/equicordplugins/hideServers/HiddenServersStore.ts +++ b/src/equicordplugins/hideServers/HiddenServersStore.ts @@ -6,13 +6,12 @@ import * as DataStore from "@api/DataStore"; import { Guild } from "@vencord/discord-types"; -import { findStoreLazy, proxyLazyWebpack } from "@webpack"; -import { Flux, FluxDispatcher, GuildStore } from "@webpack/common"; +import { proxyLazyWebpack } from "@webpack"; +import { Flux, FluxDispatcher, GuildStore, SortedGuildStore } from "@webpack/common"; export const HiddenServersStore = proxyLazyWebpack(() => { const { Store } = Flux; - const SortedGuildStore = findStoreLazy("SortedGuildStore"); const DB_KEY = "HideServers_servers"; class HiddenServersStore extends Store { public _hiddenGuilds: Set = new Set(); diff --git a/src/equicordplugins/hideServers/components/HiddenServersMenu.tsx b/src/equicordplugins/hideServers/components/HiddenServersMenu.tsx index 863a6b848..ea425d61e 100644 --- a/src/equicordplugins/hideServers/components/HiddenServersMenu.tsx +++ b/src/equicordplugins/hideServers/components/HiddenServersMenu.tsx @@ -12,9 +12,7 @@ import { getGuildAcronym } from "@utils/discord"; import { classes } from "@utils/misc"; import { Guild, RenderModalProps } from "@vencord/discord-types"; import { findCssClassesLazy } from "@webpack"; -import { Button, closeModal, IconUtils, Modal,openModal, useStateFromStores } from "@webpack/common"; - -import { SortedGuildStore } from ".."; +import { Button, closeModal, IconUtils, Modal, openModal, SortedGuildStore, useStateFromStores } from "@webpack/common"; const cl = classNameFactory("vc-hideservers-"); const IconClasses = findCssClassesLazy("icon", "acronym", "childWrapper"); diff --git a/src/equicordplugins/hideServers/index.tsx b/src/equicordplugins/hideServers/index.tsx index 9e0453975..0fee29aa8 100644 --- a/src/equicordplugins/hideServers/index.tsx +++ b/src/equicordplugins/hideServers/index.tsx @@ -18,8 +18,7 @@ import { import { EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; import { Guild } from "@vencord/discord-types"; -import { findStoreLazy } from "@webpack"; -import { Menu, React, useStateFromStores } from "@webpack/common"; +import { Menu, React, SortedGuildStore, useStateFromStores } from "@webpack/common"; import hiddenServersButton from "./components/HiddenServersButton"; import { HiddenServersStore } from "./HiddenServersStore"; @@ -39,8 +38,6 @@ type qsResult = { }; }; -export const SortedGuildStore = findStoreLazy("SortedGuildStore"); - const Patch: NavContextMenuPatchCallback = ( children, { guild }: { guild: Guild; } diff --git a/src/equicordplugins/homeTyping/index.tsx b/src/equicordplugins/homeTyping/index.tsx index d612771cb..2c17cad14 100644 --- a/src/equicordplugins/homeTyping/index.tsx +++ b/src/equicordplugins/homeTyping/index.tsx @@ -9,13 +9,12 @@ import "./styles.css"; import { Devs } from "@utils/constants"; import { classNameFactory } from "@utils/css"; import definePlugin from "@utils/types"; -import { findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { TypingStore, UserStore, useStateFromStores } from "@webpack/common"; +import { findComponentByCodeLazy } from "@webpack"; +import { PrivateChannelSortStore, TypingStore, UserStore, useStateFromStores } from "@webpack/common"; const cl = classNameFactory("vc-home-typing-"); const ThreeDots = findComponentByCodeLazy("Math.min(1,Math.max(", "dotRadius:"); -const PrivateChannelSortStore = findStoreLazy("PrivateChannelSortStore") as { getPrivateChannelIds: () => string[]; }; export default definePlugin({ name: "HomeTyping", diff --git a/src/equicordplugins/instantScreenshare/index.tsx b/src/equicordplugins/instantScreenshare/index.tsx index c65def667..fa81ec5e7 100644 --- a/src/equicordplugins/instantScreenshare/index.tsx +++ b/src/equicordplugins/instantScreenshare/index.tsx @@ -10,8 +10,8 @@ import { Paragraph } from "@components/Paragraph"; import { Devs, EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; import { VoiceState } from "@vencord/discord-types"; -import { findByCodeLazy, findStoreLazy } from "@webpack"; -import { ChannelStore, MediaEngineStore, PermissionsBits, PermissionStore, SelectedChannelStore, showToast, Toasts, UserStore, VoiceActions, WindowStore } from "@webpack/common"; +import { findByCodeLazy } from "@webpack"; +import { ApplicationStreamingSettingsStore, ChannelStore, MediaEngineStore, PermissionsBits, PermissionStore, SelectedChannelStore, showToast, Toasts, UserStore, VoiceActions, WindowStore } from "@webpack/common"; import { getCurrentMedia, settings } from "./utils"; @@ -19,7 +19,6 @@ let hasStreamed, isStreaming, streamKey; const startStream = findByCodeLazy('type:"STREAM_START"'); const stopStream = findByCodeLazy('type:"STREAM_STOP"'); const StreamPreviewSettings = getUserSettingLazy("voiceAndVideo", "disableStreamPreviews")!; -const ApplicationStreamingSettingsStore = findStoreLazy("ApplicationStreamingSettingsStore"); async function autoStartStream(instant = true) { if (!instant && !WindowStore.isFocused() && settings.store.focusDiscord) return; diff --git a/src/equicordplugins/messageLoggerEnhanced/utils/contextMenu.tsx b/src/equicordplugins/messageLoggerEnhanced/utils/contextMenu.tsx index e953f5ec6..2f4a40660 100644 --- a/src/equicordplugins/messageLoggerEnhanced/utils/contextMenu.tsx +++ b/src/equicordplugins/messageLoggerEnhanced/utils/contextMenu.tsx @@ -5,16 +5,13 @@ */ import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu"; -import { findStoreLazy } from "@webpack"; -import { FluxDispatcher, Menu, MessageActions, React, Toasts, UserStore } from "@webpack/common"; +import { FluxDispatcher, Menu, MessageActions, React, SortedGuildStore, Toasts, UserStore } from "@webpack/common"; import { openLogModal } from "../components/LogsModal"; import { deleteMessageIDB } from "../db"; import { settings } from "../index"; import { addToXAndRemoveFromOpposite, ListType, removeFromX } from "."; -const SortedGuildStore = findStoreLazy("SortedGuildStore"); - const idFunctions = { Folder: props => props?.folderId && diff --git a/src/equicordplugins/messageLoggerEnhanced/utils/index.ts b/src/equicordplugins/messageLoggerEnhanced/utils/index.ts index d87227eb8..8d08d40b6 100644 --- a/src/equicordplugins/messageLoggerEnhanced/utils/index.ts +++ b/src/equicordplugins/messageLoggerEnhanced/utils/index.ts @@ -17,8 +17,7 @@ */ import { Settings } from "@api/Settings"; -import { findStoreLazy } from "@webpack"; -import { ChannelStore, SelectedChannelStore, UserStore } from "@webpack/common"; +import { ChannelStore, SelectedChannelStore, UserGuildSettingsStore, UserStore } from "@webpack/common"; import { settings } from "../index"; import { LoggedMessageJSON } from "../types"; @@ -78,8 +77,6 @@ interface ShouldIgnoreArguments { const EPHEMERAL = 64; -const UserGuildSettingsStore = findStoreLazy("UserGuildSettingsStore"); - /** * the function `shouldIgnore` evaluates whether a message should be ignored or kept, following a priority hierarchy: User > Channel > Server. * In this hierarchy, whitelisting takes priority; if any element (User, Channel, or Server) is whitelisted, the message is kept. @@ -151,8 +148,8 @@ export function shouldIgnore({ channelId, authorId, guildId, flags, bot, ghostPi if (isBlacklisted && (!isAuthorWhitelisted || !isChannelWhitelisted)) return true; // ignore if (guildId != null && shouldIgnoreMutedGuilds && UserGuildSettingsStore.isMuted(guildId)) return true; // ignore - if (channelId != null && shouldIgnoreMutedCategories && UserGuildSettingsStore.isCategoryMuted(guildId, channelId)) return true; // ignore - if (channelId != null && shouldIgnoreMutedChannels && UserGuildSettingsStore.isChannelMuted(guildId, channelId)) return true; // ignore + if (channelId != null && shouldIgnoreMutedCategories && UserGuildSettingsStore.isCategoryMuted(guildId!, channelId)) return true; // ignore + if (channelId != null && shouldIgnoreMutedChannels && UserGuildSettingsStore.isChannelMuted(guildId!, channelId)) return true; // ignore return false; // keep; } diff --git a/src/equicordplugins/pingNotifications/index.tsx b/src/equicordplugins/pingNotifications/index.tsx index 1d96249b5..5479d3eed 100644 --- a/src/equicordplugins/pingNotifications/index.tsx +++ b/src/equicordplugins/pingNotifications/index.tsx @@ -8,7 +8,6 @@ import { showNotification } from "@api/Notifications"; import { definePluginSettings } from "@api/Settings"; import { EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findStoreLazy } from "@webpack"; import { ChannelStore, GuildStore, @@ -16,11 +15,10 @@ import { PresenceStore, RelationshipStore, SelectedChannelStore, + UserGuildSettingsStore, UserStore } from "@webpack/common"; -const UserGuildSettingsStore = findStoreLazy("UserGuildSettingsStore"); - const settings = definePluginSettings({ friends: { type: OptionType.BOOLEAN, @@ -61,7 +59,7 @@ function checkIfMuted(channel) { if (!settings.store.ignoreMuted) return false; if (!channel) return false; - if (channel.isMuted?.()) return true; + if (channel.isMuted()) return true; const isDM = [1, 3].includes(channel.type); if (isDM) { @@ -69,17 +67,15 @@ function checkIfMuted(channel) { for (const userId of recipientIds) { if (RelationshipStore.isBlocked(userId)) return true; } - - if (UserGuildSettingsStore?.getMutedChannels?.()?.includes?.(channel.id)) return true; } if (channel.guild_id) { const guild = GuildStore.getGuild(channel.guild_id); if (UserGuildSettingsStore.isMuted(channel.guild_id)) return true; - if (UserGuildSettingsStore?.isMuted?.(channel.guild_id)) return true; - if (UserGuildSettingsStore?.isChannelMuted?.(channel.guild_id, channel.id)) return true; - if (UserGuildSettingsStore?.isCategoryMuted?.(channel.guild_id, channel.id)) return true; + if (UserGuildSettingsStore.isMuted(channel.guild_id)) return true; + if (UserGuildSettingsStore.isChannelMuted(channel.guild_id, channel.id)) return true; + if (UserGuildSettingsStore.isCategoryMuted(channel.guild_id, channel.id)) return true; } return false; diff --git a/src/equicordplugins/profileSets/utils/actions.ts b/src/equicordplugins/profileSets/utils/actions.ts index dd1eeba6b..7611522b9 100644 --- a/src/equicordplugins/profileSets/utils/actions.ts +++ b/src/equicordplugins/profileSets/utils/actions.ts @@ -6,17 +6,14 @@ import { isNonNullish } from "@utils/guards"; import { ProfilePreset } from "@vencord/discord-types"; -import { findStoreLazy } from "@webpack"; -import { showToast, Toasts } from "@webpack/common"; +import { showToast, Toasts, UserProfileSettingsStore } from "@webpack/common"; import { getCurrentProfile } from "./profile"; import { addPreset, movePresetInArray, presets, PresetSection, type ProfilePresetEx, removePreset, replaceAllPresets, savePresetsData, updatePreset } from "./storage"; -const UserProfileSettingsStore = findStoreLazy("UserProfileSettingsStore"); - function isImageInput(value: unknown): value is string | { imageUri: string; } { if (typeof value === "string") return value.length > 0; - return typeof value === "object" && isNonNullish(value) && "imageUri" in value && typeof (value as { imageUri: unknown }).imageUri === "string"; + return typeof value === "object" && isNonNullish(value) && "imageUri" in value && typeof (value as { imageUri: unknown; }).imageUri === "string"; } function getFreshPendingAvatar(section: PresetSection, guildId?: string): string | null { diff --git a/src/equicordplugins/profileSets/utils/profile.ts b/src/equicordplugins/profileSets/utils/profile.ts index 48c023a97..030dc2bd2 100644 --- a/src/equicordplugins/profileSets/utils/profile.ts +++ b/src/equicordplugins/profileSets/utils/profile.ts @@ -6,10 +6,8 @@ import { getUserSettingLazy } from "@api/UserSettings"; import { AvatarDecorationData, CustomStatus, DisplayNameStyles, Nameplate, ProfileEffect, ProfilePreset } from "@vencord/discord-types"; -import { findStoreLazy } from "@webpack"; -import { FluxDispatcher, GuildMemberStore, IconUtils, UserProfileStore, UserStore } from "@webpack/common"; +import { FluxDispatcher, GuildMemberStore, IconUtils, UserProfileSettingsStore, UserProfileStore, UserStore } from "@webpack/common"; -const UserProfileSettingsStore = findStoreLazy("UserProfileSettingsStore"); const CustomStatusSettings = getUserSettingLazy("status", "customStatus")!; type PendingChanges = Record & { @@ -28,7 +26,7 @@ type PendingChanges = Record & { pendingPrimaryGuildId?: string | null; }; -type ImageInput = string | { imageUri: string; [key: string]: unknown; } | null | undefined; +type ImageInput = string | { imageUri: string;[key: string]: unknown; } | null | undefined; type AvatarDecorationLike = AvatarDecorationData & { label?: string; type?: number; diff --git a/src/equicordplugins/questify/utils/completion.ts b/src/equicordplugins/questify/utils/completion.ts index 2ac077ae1..94f1161b8 100644 --- a/src/equicordplugins/questify/utils/completion.ts +++ b/src/equicordplugins/questify/utils/completion.ts @@ -8,14 +8,13 @@ import type { PluginNative } from "@utils/types"; import type { Quest, User } from "@vencord/discord-types"; import { QuestTaskType } from "@vencord/discord-types/enums"; import { findByCodeLazy, findLazy } from "@webpack"; -import { FluxDispatcher, QuestStore, RestAPI, showToast, Toasts, UserStore } from "@webpack/common"; +import { AuthorizedAppsStore, FluxDispatcher, QuestStore, RestAPI, showToast, Toasts, UserStore } from "@webpack/common"; import { getCurrentUserId, getQuestifySettings } from "../settings/access"; import { autoCompleteQuestTaskTypes, isDesktopCompatible } from "../settings/def"; import { resetQuestsToResume } from "../settings/fetching"; import { getIgnoredQuestIDs } from "../settings/ignoredQuests"; import { rerenderQuests } from "../settings/rerender"; -import { AuthorizedAppsStore } from "./fetching"; import { normalizeQuestName } from "./filtering"; import { QL } from "./logging"; import { getQuestStatus, getQuestStoredProgress, isVideoQuestTask, QuestStatus, QuestTask, refreshQuest } from "./questState"; diff --git a/src/equicordplugins/questify/utils/fetching.ts b/src/equicordplugins/questify/utils/fetching.ts index 512d5b847..1ed005a1a 100644 --- a/src/equicordplugins/questify/utils/fetching.ts +++ b/src/equicordplugins/questify/utils/fetching.ts @@ -9,7 +9,7 @@ import { showNotification } from "@api/Notifications"; import { sleep } from "@utils/misc"; import type { PluginNative } from "@utils/types"; import type { Quest } from "@vencord/discord-types"; -import { findByCodeLazy, findStoreLazy } from "@webpack"; +import { findByCodeLazy } from "@webpack"; import { QuestStore, RestAPI } from "@webpack/common"; import { NavigationRouter } from "@webpack/common/utils"; @@ -19,7 +19,6 @@ import { getNewQuests, normalizeQuestName, type QuestIncludedTypes, questMatches import { QL } from "./logging"; import { QUEST_PAGE } from "./ui"; -export const AuthorizedAppsStore = findStoreLazy("AuthorizedAppsStore"); const QuestifyNative = VencordNative?.pluginHelpers?.Questify as PluginNative | undefined; export function snakeToCamel(obj: any): any { diff --git a/src/equicordplugins/sidebarChat/index.tsx b/src/equicordplugins/sidebarChat/index.tsx index 4359ec286..fff6ab888 100644 --- a/src/equicordplugins/sidebarChat/index.tsx +++ b/src/equicordplugins/sidebarChat/index.tsx @@ -18,11 +18,11 @@ import { findByPropsLazy, findComponentByCodeLazy, findCssClassesLazy, - findStoreLazy, } from "@webpack"; import { ChannelActionCreators, ChannelRouter, + ChannelSectionStore, ChannelStore, FluxDispatcher, GuildStore, @@ -79,8 +79,6 @@ const ChatInputTypes = findByPropsLazy("FORM", "NORMAL"); const Sidebars = findByPropsLazy("ThreadSidebar", "MessageRequestSidebar"); const ChatClasses = findCssClassesLazy("threadSidebarOpen", "loader"); -const ChannelSectionStore = findStoreLazy("ChannelSectionStore"); - const requireForumView = extractAndLoadChunksLazy( ["Missing channel in Channel.renderHeaderToolbar"], /Promise\.all\(\[((?:\i\.e\("\d+"\),?)+)\]\)\.then\(\i\.bind\(\i,(\d+)\)\)[^}]{0,100}?name:"ForumChannel"/ @@ -377,7 +375,7 @@ export default definePlugin({ const [channelSidebar, guildSidebar] = useStateFromStores( [ChannelSectionStore, SelectedChannelStore, ChannelStore], () => { const currentChannelId = SelectedChannelStore.getChannelId(); - const currentGuildId = SelectedGuildStore.getGuildId(); + const currentGuildId = SelectedGuildStore.getGuildId()!; return [ ChannelSectionStore.getSidebarState(currentChannelId), ChannelSectionStore.getGuildSidebarState(currentGuildId), diff --git a/src/equicordplugins/unreadBadgeCount/index.tsx b/src/equicordplugins/unreadBadgeCount/index.tsx index 145ae5025..5ed1da3f1 100644 --- a/src/equicordplugins/unreadBadgeCount/index.tsx +++ b/src/equicordplugins/unreadBadgeCount/index.tsx @@ -9,11 +9,9 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { Channel } from "@vencord/discord-types"; -import { findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { ReadStateStore, useStateFromStores } from "@webpack/common"; +import { findComponentByCodeLazy } from "@webpack"; +import { JoinedThreadsStore, ReadStateStore, UserGuildSettingsStore, useStateFromStores } from "@webpack/common"; -const UserGuildSettingsStore = findStoreLazy("UserGuildSettingsStore"); -const JoinedThreadsStore = findStoreLazy("JoinedThreadsStore"); const NumberBadge = findComponentByCodeLazy("BADGE_NOTIFICATION_BACKGROUND", "let{count:"); const settings = definePluginSettings({ diff --git a/src/equicordplugins/voiceButtons/utils.tsx b/src/equicordplugins/voiceButtons/utils.tsx index 993e30c90..260f02a5d 100644 --- a/src/equicordplugins/voiceButtons/utils.tsx +++ b/src/equicordplugins/voiceButtons/utils.tsx @@ -7,13 +7,12 @@ import "./styles.css"; import { Icon, User } from "@vencord/discord-types"; -import { findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { Button, ChannelActionCreators, ChannelStore, GuildActions, MediaEngineStore, NavigationRouter, PermissionsBits, PermissionStore, Tooltip, UserStore, VoiceActions, VoiceStateStore } from "@webpack/common"; +import { findComponentByCodeLazy } from "@webpack"; +import { Button, ChannelActionCreators, ChannelStore, GuildActions, MediaEngineStore, NavigationRouter, PermissionsBits, PermissionStore, SoundboardStore, Tooltip, UserStore, VoiceActions, VoiceStateStore } from "@webpack/common"; import { JSX } from "react"; import { settings } from "./settings"; -const SoundboardStore = findStoreLazy("SoundboardStore"); const DeafenIconSelf = findComponentByCodeLazy("M22.7 2.7a1", "1.4l20-20ZM17") as Icon; const DeafenIconOther = findComponentByCodeLazy("M21.76.83a5.02", "M12.38") as Icon; const ChatIcon = findComponentByCodeLazy(".css,d:\"M12 22a10") as Icon; diff --git a/src/equicordplugins/voiceChannelLog/components/VoiceChannelLogModal.tsx b/src/equicordplugins/voiceChannelLog/components/VoiceChannelLogModal.tsx index 60bf5a793..aad73366c 100644 --- a/src/equicordplugins/voiceChannelLog/components/VoiceChannelLogModal.tsx +++ b/src/equicordplugins/voiceChannelLog/components/VoiceChannelLogModal.tsx @@ -6,15 +6,12 @@ import { classes } from "@utils/misc"; import { Channel, RenderModalProps } from "@vencord/discord-types"; -import { findStoreLazy } from "@webpack"; -import { Modal, openModal, React, ScrollerThin } from "@webpack/common"; +import { AccessibilityStore, Modal, openModal, React, ScrollerThin } from "@webpack/common"; import { clearLogs, getVcLogs, vcLogSubscribe } from "../logs"; import { cl } from "../utils"; import { VoiceChannelLogEntryComponent } from "./VoiceChannelLogEntryComponent"; -const AccessibilityStore = findStoreLazy("AccessibilityStore"); - export function openVoiceChannelLog(channel: Channel) { return openModal(props => ( diff --git a/src/plugins/betterFolders/FolderSideBar.tsx b/src/plugins/betterFolders/FolderSideBar.tsx index fb33d9317..32e08539e 100644 --- a/src/plugins/betterFolders/FolderSideBar.tsx +++ b/src/plugins/betterFolders/FolderSideBar.tsx @@ -18,10 +18,10 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { findComponentByCodeLazy } from "@webpack"; -import { Animations, ChannelRTCStore, useStateFromStores } from "@webpack/common"; +import { Animations, ChannelRTCStore, ExpandedGuildFolderStore, SortedGuildStore, useStateFromStores } from "@webpack/common"; import type { CSSProperties } from "react"; -import { ExpandedGuildFolderStore, settings, SortedGuildStore } from "."; +import { settings } from "."; const GuildsBar = findComponentByCodeLazy('("guildsnav")'); @@ -29,11 +29,11 @@ function getExpandedFolderIds() { const expandedFolders = ExpandedGuildFolderStore.getExpandedFolders(); const folders = SortedGuildStore.getGuildFolders(); - const expandedFolderIds = new Set(); + const expandedFolderIds = new Set(); for (const folder of folders) { - if (expandedFolders.has(folder.folderId) && folder.guildIds?.length) { - expandedFolderIds.add(folder.folderId); + if (expandedFolders.has(folder.folderId!) && folder.guildIds?.length) { + expandedFolderIds.add(folder.folderId!); } } diff --git a/src/plugins/betterFolders/index.tsx b/src/plugins/betterFolders/index.tsx index da29500b1..b530cd9e6 100644 --- a/src/plugins/betterFolders/index.tsx +++ b/src/plugins/betterFolders/index.tsx @@ -23,8 +23,8 @@ import { Devs } from "@utils/constants"; import { getIntlMessage } from "@utils/discord"; import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findStoreLazy } from "@webpack"; -import { FluxDispatcher } from "@webpack/common"; +import { findByPropsLazy } from "@webpack"; +import { ExpandedGuildFolderStore, FluxDispatcher, SortedGuildStore } from "@webpack/common"; import { ReactNode } from "react"; import FolderSideBar from "./FolderSideBar"; @@ -35,8 +35,6 @@ enum FolderIconDisplay { MoreThanOneFolderExpanded } -export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore"); -export const SortedGuildStore = findStoreLazy("SortedGuildStore"); const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand"); let lastGuildId = null as string | null; diff --git a/src/plugins/betterSessions/index.tsx b/src/plugins/betterSessions/index.tsx index 5fba7d8b8..72ff59ce0 100644 --- a/src/plugins/betterSessions/index.tsx +++ b/src/plugins/betterSessions/index.tsx @@ -24,14 +24,13 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Paragraph } from "@components/Paragraph"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findComponentByCodeLazy, findCssClassesLazy, findStoreLazy } from "@webpack"; -import { Constants, React, RestAPI, SettingsRouter, Tooltip } from "@webpack/common"; +import { findComponentByCodeLazy, findCssClassesLazy } from "@webpack"; +import { AuthSessionsStore, Constants, React, RestAPI, SettingsRouter, Tooltip } from "@webpack/common"; import { NewButton, RenameButton } from "./components/RenameButton"; import { Session, SessionInfo } from "./types"; import { cl, fetchNamesFromDataStore, getDefaultName, GetOsColor, GetPlatformIcon, savedSessionsCache, saveSessionsToDataStore } from "./utils"; -const AuthSessionsStore = findStoreLazy("AuthSessionsStore"); const TimestampClasses = findCssClassesLazy("timestamp", "blockquoteContainer"); const BlobMask = findComponentByCodeLazy("!1,lowerBadgeSize:"); @@ -172,7 +171,7 @@ export default definePlugin({ flux: { USER_SETTINGS_ACCOUNT_RESET_AND_CLOSE_FORM() { - const lastFetchedHashes: string[] = AuthSessionsStore.getSessions().map((session: SessionInfo["session"]) => session.id_hash); + const lastFetchedHashes: string[] = AuthSessionsStore.getSessions().map(session => session.id_hash); // Add new sessions to cache lastFetchedHashes.forEach(idHash => { diff --git a/src/plugins/clientTheme/components/Settings.tsx b/src/plugins/clientTheme/components/Settings.tsx index e484a8127..e16f899f3 100644 --- a/src/plugins/clientTheme/components/Settings.tsx +++ b/src/plugins/clientTheme/components/Settings.tsx @@ -11,13 +11,12 @@ import { relativeLuminance } from "@plugins/clientTheme/utils/colorUtils"; import { createOrUpdateThemeColorVars } from "@plugins/clientTheme/utils/styleUtils"; import { classNameFactory } from "@utils/css"; import { Margins } from "@utils/margins"; -import { findByCodeLazy, findStoreLazy } from "@webpack"; -import { Button, ColorPicker, ThemeStore, useStateFromStores } from "@webpack/common"; +import { findByCodeLazy } from "@webpack"; +import { Button, ClientThemesBackgroundStore, ColorPicker, ThemeStore, useStateFromStores } from "@webpack/common"; import { settings } from ".."; const saveClientTheme = findByCodeLazy('type:"UNSYNCED_USER_SETTINGS_UPDATE', '"system"==='); -const NitroThemeStore = findStoreLazy("ClientThemesBackgroundStore"); const cl = classNameFactory("vc-clientTheme-"); @@ -44,7 +43,7 @@ export function ThemeSettingsComponent() { const isLightTheme = currentTheme === "light"; const oppositeTheme = isLightTheme ? "Dark" : "Light"; - const nitroThemeEnabled = useStateFromStores([NitroThemeStore], () => NitroThemeStore.gradientPreset != null); + const nitroThemeEnabled = useStateFromStores([ClientThemesBackgroundStore], () => ClientThemesBackgroundStore.gradientPreset != null); const selectedLuminance = relativeLuminance(settings.store.color); diff --git a/src/plugins/gameActivityToggle/index.tsx b/src/plugins/gameActivityToggle/index.tsx index ad95b5d15..3024a91e1 100644 --- a/src/plugins/gameActivityToggle/index.tsx +++ b/src/plugins/gameActivityToggle/index.tsx @@ -23,22 +23,10 @@ import { getUserSettingLazy } from "@api/UserSettings"; import equicordToolbox from "@equicordplugins/equicordToolbox"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { FluxStore } from "@vencord/discord-types"; -import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { Menu, Popout, useRef, useState, useStateFromStores } from "@webpack/common"; -interface ConnectedAccount { - id: string; - type: string; - revoked: boolean; - showActivity: boolean; -} - -interface ConnectedAccountsStore extends FluxStore { - getAccounts(): ConnectedAccount[]; -} +import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; +import { ConnectedAccountsStore, Menu, Popout, useRef, useState, useStateFromStores } from "@webpack/common"; const Button = findComponentByCodeLazy(".GREEN,positionKeyStemOverride:"); -const ConnectedAccountsStore = findStoreLazy("ConnectedAccountsStore") as ConnectedAccountsStore; const ConnectedAccountActions = findByPropsLazy("setShowActivity"); const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame")!; diff --git a/src/plugins/memberCount/MemberCount.tsx b/src/plugins/memberCount/MemberCount.tsx index 0d925c12f..459c3d808 100644 --- a/src/plugins/memberCount/MemberCount.tsx +++ b/src/plugins/memberCount/MemberCount.tsx @@ -6,9 +6,9 @@ import { getCurrentChannel } from "@utils/discord"; import { isObjectEmpty } from "@utils/misc"; -import { ChannelStore, GuildMemberCountStore, PermissionsBits, PermissionStore, SelectedChannelStore, Tooltip, useEffect, useStateFromStores, VoiceStateStore } from "@webpack/common"; +import { ChannelMemberStore, ChannelStore, GuildMemberCountStore, PermissionsBits, PermissionStore, SelectedChannelStore, ThreadMemberListStore, Tooltip, useEffect, useStateFromStores, VoiceStateStore } from "@webpack/common"; -import { ChannelMemberStore, cl, numberFormat, settings, ThreadMemberListStore } from "."; +import { cl, numberFormat, settings } from "."; import { CircleIcon } from "./CircleIcon"; import { OnlineMemberCountStore } from "./OnlineMemberCountStore"; import { VoiceIcon } from "./VoiceIcon"; diff --git a/src/plugins/memberCount/index.tsx b/src/plugins/memberCount/index.tsx index 2c7f6688b..ca82a1db6 100644 --- a/src/plugins/memberCount/index.tsx +++ b/src/plugins/memberCount/index.tsx @@ -23,18 +23,9 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { classNameFactory } from "@utils/css"; import definePlugin, { OptionType } from "@utils/types"; -import { FluxStore } from "@vencord/discord-types"; -import { findStoreLazy } from "@webpack"; import { MemberCount } from "./MemberCount"; -export const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & { - getProps(guildId?: string, channelId?: string): { groups: { count: number; id: string; }[]; }; -}; -export const ThreadMemberListStore = findStoreLazy("ThreadMemberListStore") as FluxStore & { - getMemberListSections(channelId?: string): { [sectionId: string]: { sectionId: string; userIds: string[]; }; }; -}; - export const settings = definePluginSettings({ toolTip: { type: OptionType.BOOLEAN, diff --git a/src/plugins/noBlockedMessages/index.ts b/src/plugins/noBlockedMessages/index.ts index 5780d8b57..87bc7f175 100644 --- a/src/plugins/noBlockedMessages/index.ts +++ b/src/plugins/noBlockedMessages/index.ts @@ -22,10 +22,7 @@ import { Devs, EquicordDevs } from "@utils/constants"; import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import { Message, User } from "@vencord/discord-types"; -import { findStoreLazy } from "@webpack"; -import { MessageStore, RelationshipStore } from "@webpack/common"; - -const ReferencedMessageStore = findStoreLazy("ReferencedMessageStore"); +import { MessageStore, ReferencedMessageStore, RelationshipStore } from "@webpack/common"; interface ChannelStreamDividerProps { type: "DIVIDER", diff --git a/src/plugins/pinDms/data.ts b/src/plugins/pinDms/data.ts index 38b7f9eb0..73a8c00cd 100644 --- a/src/plugins/pinDms/data.ts +++ b/src/plugins/pinDms/data.ts @@ -4,9 +4,9 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { PinOrder, PrivateChannelSortStore, settings } from "@plugins/pinDms"; +import { PinOrder, settings } from "@plugins/pinDms"; import { useForceUpdater } from "@utils/react"; -import { UserStore } from "@webpack/common"; +import { PrivateChannelSortStore, UserStore } from "@webpack/common"; export interface Category { id: string; diff --git a/src/plugins/pinDms/index.tsx b/src/plugins/pinDms/index.tsx index 3def8f9ec..b26e14006 100644 --- a/src/plugins/pinDms/index.tsx +++ b/src/plugins/pinDms/index.tsx @@ -12,7 +12,7 @@ import { Devs } from "@utils/constants"; import { classes } from "@utils/misc"; import definePlugin, { OptionType, StartAt } from "@utils/types"; import { Channel } from "@vencord/discord-types"; -import { findCssClassesLazy, findStoreLazy } from "@webpack"; +import { findCssClassesLazy } from "@webpack"; import { Clickable, ContextMenuApi, FluxDispatcher, Menu, React } from "@webpack/common"; import { contextMenus } from "./components/contextMenu"; @@ -28,8 +28,6 @@ interface ChannelComponentProps { const headerClasses = findCssClassesLazy("privateChannelsHeaderContainer", "headerText"); -export const PrivateChannelSortStore = findStoreLazy("PrivateChannelSortStore") as { getPrivateChannelIds: () => string[]; }; - export let instance: any; export const enum PinOrder { diff --git a/src/plugins/platformIndicators/index.tsx b/src/plugins/platformIndicators/index.tsx index be877413d..46168a66e 100644 --- a/src/plugins/platformIndicators/index.tsx +++ b/src/plugins/platformIndicators/index.tsx @@ -23,23 +23,8 @@ import { Devs, EquicordDevs } from "@utils/constants"; import { classes } from "@utils/misc"; import definePlugin, { OptionType } from "@utils/types"; import { DiscordPlatform, User } from "@vencord/discord-types"; -import { filters, findStoreLazy, mapMangledModuleLazy } from "@webpack"; -import { AuthenticationStore, PresenceStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common"; - -export interface Session { - sessionId: string; - status: string; - active: boolean; - clientInfo: { - version: number; - os: string; - client: string; - }; -} - -const SessionsStore = findStoreLazy("SessionsStore") as { - getSessions(): Record; -}; +import { filters, mapMangledModuleLazy } from "@webpack"; +import { AuthenticationStore, PresenceStore, SessionsStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common"; const { useStatusFillColor } = mapMangledModuleLazy([".5625*", "translate"], { useStatusFillColor: filters.byCode(".hex") diff --git a/src/plugins/relationshipNotifier/functions.ts b/src/plugins/relationshipNotifier/functions.ts index da7838b9c..30d5c3fb6 100644 --- a/src/plugins/relationshipNotifier/functions.ts +++ b/src/plugins/relationshipNotifier/functions.ts @@ -18,11 +18,11 @@ import { getUniqueUsername, openUserProfile } from "@utils/discord"; import { ChannelType, RelationshipType } from "@vencord/discord-types/enums"; -import { UserUtils } from "@webpack/common"; +import { GuildAvailabilityStore, UserUtils } from "@webpack/common"; import settings from "./settings"; import { ChannelDelete, GuildDelete, RelationshipRemove } from "./types"; -import { deleteGroup, deleteGuild, getGroup, getGuild, GuildAvailabilityStore, notify } from "./utils"; +import { deleteGroup, deleteGuild, getGroup, getGuild, notify } from "./utils"; let manuallyRemovedFriend: string | undefined; let manuallyRemovedGuild: string | undefined; diff --git a/src/plugins/relationshipNotifier/utils.ts b/src/plugins/relationshipNotifier/utils.ts index 24c7cdefc..e89eb3a2a 100644 --- a/src/plugins/relationshipNotifier/utils.ts +++ b/src/plugins/relationshipNotifier/utils.ts @@ -20,21 +20,12 @@ import * as DataStore from "@api/DataStore"; import { popNotice, showNotice } from "@api/Notices"; import { showNotification } from "@api/Notifications"; import { getUniqueUsername, openUserProfile } from "@utils/discord"; -import { FluxStore } from "@vencord/discord-types"; import { ChannelType, RelationshipType } from "@vencord/discord-types/enums"; -import { findStoreLazy } from "@webpack"; -import { ChannelStore, GuildMemberStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common"; +import { ChannelStore, GuildAvailabilityStore, GuildMemberStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common"; import settings from "./settings"; import { 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(); const groups = new Map(); const friends = { diff --git a/src/plugins/serverListIndicators/index.tsx b/src/plugins/serverListIndicators/index.tsx index cc082ee60..cd5022491 100644 --- a/src/plugins/serverListIndicators/index.tsx +++ b/src/plugins/serverListIndicators/index.tsx @@ -25,8 +25,7 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs, EquicordDevs } from "@utils/constants"; import { classNameFactory } from "@utils/css"; import definePlugin, { OptionType } from "@utils/types"; -import { findStoreLazy } from "@webpack"; -import { GuildStore, PresenceStore, RelationshipStore, Tooltip, useStateFromStores } from "@webpack/common"; +import { GuildStore, PresenceStore, RelationshipStore, Tooltip, UserGuildJoinRequestStore, useStateFromStores } from "@webpack/common"; const enum IndicatorType { SERVER = 1 << 0, @@ -37,8 +36,6 @@ const enum IndicatorType { let onlineFriendsCount = 0; let guildCount = 0; -const UserGuildJoinRequestStore = findStoreLazy("UserGuildJoinRequestStore"); - function FriendsIndicator() { onlineFriendsCount = useStateFromStores([RelationshipStore, PresenceStore], () => { let count = 0; diff --git a/src/plugins/showMeYourName/index.tsx b/src/plugins/showMeYourName/index.tsx index 7f705cfe3..984acfae0 100644 --- a/src/plugins/showMeYourName/index.tsx +++ b/src/plugins/showMeYourName/index.tsx @@ -19,15 +19,13 @@ import { Devs, EquicordDevs } from "@utils/constants"; import { classNameFactory } from "@utils/index"; import definePlugin, { OptionType } from "@utils/types"; import { GuildMember, Message, RenderModalProps, User } from "@vencord/discord-types"; -import { findByCodeLazy, findStoreLazy } from "@webpack"; -import { ChannelStore, GuildMemberStore, GuildStore, Menu, MessageStore, Modal, openModal, RelationshipStore, StreamerModeStore, TextInput, useEffect, useState } from "@webpack/common"; +import { findByCodeLazy } from "@webpack"; +import { AccessibilityStore, ChannelStore, GuildMemberStore, GuildStore, Menu, MessageStore, Modal, openModal, RelationshipStore, StreamerModeStore, TextInput, useEffect, UserStore, useState } from "@webpack/common"; import { JSX } from "react"; const SMYNC = classNameFactory(); -const UserStore = findStoreLazy("UserStore"); const wrapEmojis = findByCodeLazy("lastIndex;return"); const adjustColor = findByCodeLazy("light1", '.get("hsl.s"))'); -const AccessibilityStore = findStoreLazy("AccessibilityStore"); const roleColorPattern = /^role((?:\+|-)\d{0,4})?$/iu; const symbolPattern = /^[\p{S}\p{P}]{1,3}$/iu; diff --git a/src/webpack/common/stores.ts b/src/webpack/common/stores.ts index 0716a3a2d..4ea285fa6 100644 --- a/src/webpack/common/stores.ts +++ b/src/webpack/common/stores.ts @@ -88,6 +88,26 @@ export let UserAffinitiesStore: t.UserAffinitiesStore; export let ApplicationStreamingStore: t.ApplicationStreamingStore; export let ApplicationStreamPreviewStore: t.ApplicationStreamPreviewStore; +export let SortedGuildStore: t.SortedGuildStore; +export let JoinedThreadsStore: t.JoinedThreadsStore; +export let SafetyHubStore: t.SafetyHubStore; +export let PrivateChannelSortStore: t.PrivateChannelSortStore; +export let ApplicationStreamingSettingsStore: t.ApplicationStreamingSettingsStore; +export let UserProfileSettingsStore: t.UserProfileSettingsStore; +export let AuthorizedAppsStore: t.AuthorizedAppsStore; +export let ChannelSectionStore: t.ChannelSectionStore; +export let ExpandedGuildFolderStore: t.ExpandedGuildFolderStore; +export let AuthSessionsStore: t.AuthSessionsStore; +export let ClientThemesBackgroundStore: t.ClientThemesBackgroundStore; +export let ConnectedAccountsStore: t.ConnectedAccountsStore; +export let ChannelMemberStore: t.ChannelMemberStore; +export let ThreadMemberListStore: t.ThreadMemberListStore; +export let CollapsedVoiceChannelStore: t.CollapsedVoiceChannelStore; +export let ReferencedMessageStore: t.ReferencedMessageStore; +export let SessionsStore: t.SessionsStore; +export let GuildAvailabilityStore: t.GuildAvailabilityStore; +export let UserGuildJoinRequestStore: t.UserGuildJoinRequestStore; + /** * @see jsdoc of {@link t.useStateFromStores} */ @@ -146,6 +166,27 @@ waitForStore("QuestStore", m => QuestStore = m); waitForStore("UserAffinitiesV2Store", m => UserAffinitiesStore = m); waitForStore("ApplicationStreamingStore", m => ApplicationStreamingStore = m); waitForStore("ApplicationStreamPreviewStore", m => ApplicationStreamPreviewStore = m); +waitForStore("SortedGuildStore", m => SortedGuildStore = m); +waitForStore("JoinedThreadsStore", m => JoinedThreadsStore = m); +waitForStore("SafetyHubStore", m => SafetyHubStore = m); +waitForStore("PrivateChannelSortStore", m => PrivateChannelSortStore = m); +waitForStore("ApplicationStreamingSettingsStore", m => ApplicationStreamingSettingsStore = m); +waitForStore("UserProfileSettingsStore", m => UserProfileSettingsStore = m); +waitForStore("AuthorizedAppsStore", m => AuthorizedAppsStore = m); +waitForStore("ChannelSectionStore", m => ChannelSectionStore = m); +waitForStore("ExpandedGuildFolderStore", m => ExpandedGuildFolderStore = m); +waitForStore("AuthSessionsStore", m => AuthSessionsStore = m); +waitForStore("ClientThemesBackgroundStore", m => ClientThemesBackgroundStore = m); +waitForStore("ConnectedAccountsStore", m => ConnectedAccountsStore = m); +waitForStore("ChannelMemberStore", m => ChannelMemberStore = m); +// comeback +waitForStore("ThreadMemberListStore", m => ThreadMemberListStore = m); +waitForStore("CollapsedVoiceChannelStore", m => CollapsedVoiceChannelStore = m); +waitForStore("ReferencedMessageStore", m => ReferencedMessageStore = m); +// comeback +waitForStore("SessionsStore", m => SessionsStore = m); +waitForStore("GuildAvailabilityStore", m => GuildAvailabilityStore = m); +waitForStore("UserGuildJoinRequestStore", m => UserGuildJoinRequestStore = m); waitForStore("ThemeStore", m => { ThemeStore = m; // Importing this directly causes all webpack commons to be imported, which can easily cause circular dependencies.