From b8fe8798671f7ade74483c230e5519405a0f508d Mon Sep 17 00:00:00 2001 From: thororen <78185467+thororen1234@users.noreply.github.com> Date: Fri, 25 Sep 2026 10:11:16 -0400 Subject: [PATCH] More Store Porting --- package.json | 2 +- .../src/stores/GIFPickerViewStore.d.ts | 32 +++++ .../src/stores/GuildReadStateStore.d.ts | 36 ++++++ .../src/stores/MessageRequestStore.d.ts | 9 ++ .../src/stores/SelfPresenceStore.d.ts | 19 +++ packages/discord-types/src/stores/index.d.ts | 4 + pnpm-lock.yaml | 122 +++++++++--------- src/equicordplugins/randomVoice/index.tsx | 5 +- .../richPresence/services/statsfm.ts | 8 +- src/equicordplugins/toggleVideoBind/index.ts | 7 +- src/plugins/noPendingCount/index.ts | 4 +- src/plugins/tenorGifSearch/index.tsx | 5 +- src/plugins/webPWA.browser/index.tsx | 6 +- src/webpack/common/stores.ts | 8 ++ 14 files changed, 180 insertions(+), 87 deletions(-) create mode 100644 packages/discord-types/src/stores/GIFPickerViewStore.d.ts create mode 100644 packages/discord-types/src/stores/GuildReadStateStore.d.ts create mode 100644 packages/discord-types/src/stores/MessageRequestStore.d.ts create mode 100644 packages/discord-types/src/stores/SelfPresenceStore.d.ts diff --git a/package.json b/package.json index 14c54b0fe..97c701c74 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "typescript-transform-paths": "^3.5.6", "zip-local": "^0.3.5" }, - "packageManager": "pnpm@12.5.1", + "packageManager": "pnpm@12.6.0", "engines": { "node": ">=22" } diff --git a/packages/discord-types/src/stores/GIFPickerViewStore.d.ts b/packages/discord-types/src/stores/GIFPickerViewStore.d.ts new file mode 100644 index 000000000..36adf6427 --- /dev/null +++ b/packages/discord-types/src/stores/GIFPickerViewStore.d.ts @@ -0,0 +1,32 @@ +import { FluxStore } from ".."; + +export type GIFMediaFormat = 1 | 2; +export type GIFSelectedFormat = "webm" | "tinywebp"; + +export interface GIFResultItem { + id: string; + url: string; + src: string; + gifSrc: string; + width: number; + height: number; + format: GIFMediaFormat; +} + +export interface GIFTrendingCategory { + type: "Trending" | "Category"; + name: string; + src: string; + format: GIFMediaFormat; +} + +export class GIFPickerViewStore extends FluxStore { + getAnalyticsID(): string | null; + getQuery(): string; + getResultItems(): GIFResultItem[]; + getResultQuery(): string; + getSelectedFormat(): GIFSelectedFormat; + getSuggestions(): string[]; + getTrendingCategories(): GIFTrendingCategory[]; + getTrendingSearchTerms(): string[]; +} diff --git a/packages/discord-types/src/stores/GuildReadStateStore.d.ts b/packages/discord-types/src/stores/GuildReadStateStore.d.ts new file mode 100644 index 000000000..ed557291e --- /dev/null +++ b/packages/discord-types/src/stores/GuildReadStateStore.d.ts @@ -0,0 +1,36 @@ +import { Channel, FluxStore } from ".."; +import { ReadStateType } from "../../enums"; + +export interface GuildChannelMentionCount { + count: number; + isMentionLowImportance: boolean; +} + +export interface GuildReadState { + unread: boolean; + unreadByType: Partial>; + unreadChannelId: string | null; + lowImportanceMentionCount: number; + highImportanceMentionCount: number; + mentionCounts: Record; + ncMentionCount: number; + sentinel: number; +} + +export class GuildReadStateStore extends FluxStore { + getGuildChangeSentinel(guildId: string | null): number; + getGuildHasUnreadIgnoreMuted(guildId: string): boolean; + getHighImportanceMentionCountForChannel(guildId: string | null, channelId: string): number; + getIsMentionLowImportance(guildId: string | null): boolean; + getMentionCount(guildId: string | null): number; + getMentionCountForPrivateChannel(channelId: string): GuildChannelMentionCount | number; + getMutableGuildStates(): Record; + getMutableUnreadGuilds(): Set; + getPrivateChannelMentionCount(): number; + getStoreChangeSentinel(): number; + getTotalMentionCount(excludePrivateChannels?: boolean): number; + getTotalNotificationsMentionCount(excludePrivateChannels?: boolean): number; + hasAnyUnread(): boolean; + hasUnread(guildId: string): boolean; + shouldCountChannelUnread(channel: Channel, mentionCount?: number): boolean; +} diff --git a/packages/discord-types/src/stores/MessageRequestStore.d.ts b/packages/discord-types/src/stores/MessageRequestStore.d.ts new file mode 100644 index 000000000..471f9e18e --- /dev/null +++ b/packages/discord-types/src/stores/MessageRequestStore.d.ts @@ -0,0 +1,9 @@ +import { FluxStore } from ".."; + +export class MessageRequestStore extends FluxStore { + getMessageRequestChannelIds(): Set; + getMessageRequestsCount(): number; + isAcceptedOptimistic(channelId: string): boolean; + isMessageRequest(channelId: string): boolean; + isReady(): boolean; +} diff --git a/packages/discord-types/src/stores/SelfPresenceStore.d.ts b/packages/discord-types/src/stores/SelfPresenceStore.d.ts new file mode 100644 index 000000000..e2e26f7a9 --- /dev/null +++ b/packages/discord-types/src/stores/SelfPresenceStore.d.ts @@ -0,0 +1,19 @@ +import { Activity, FluxStore, OnlineStatus } from ".."; + +export interface LocalPresence { + status: OnlineStatus; + since: number; + activities: Activity[]; + afk: boolean; +} + +export class SelfPresenceStore extends FluxStore { + findActivity(predicate: (activity: Activity) => boolean, filtered?: boolean): Activity | undefined; + getActivities(filtered?: boolean): Activity[]; + getApplicationActivity(applicationId: string, filtered?: boolean): Activity | undefined; + getHiddenActivities(): Activity[]; + getLocalPresence(): LocalPresence; + getPrimaryActivity(filtered?: boolean): Activity | undefined; + getStatus(): OnlineStatus; + getUnfilteredActivities(filtered?: boolean): Activity[]; +} diff --git a/packages/discord-types/src/stores/index.d.ts b/packages/discord-types/src/stores/index.d.ts index 65171dfea..a9f172861 100644 --- a/packages/discord-types/src/stores/index.d.ts +++ b/packages/discord-types/src/stores/index.d.ts @@ -26,11 +26,13 @@ export * from "./ExpandedGuildFolderStore"; export * from "./ExperimentStore"; export * from "./FluxStore"; export * from "./FriendsStore"; +export * from "./GIFPickerViewStore"; export * from "./GuildAvailabilityStore"; export * from "./GuildChannelStore"; export * from "./GuildMemberCountStore"; export * from "./GuildMemberStore"; export * from "./GuildProfileStore"; +export * from "./GuildReadStateStore"; export * from "./GuildRoleStore"; export * from "./GuildScheduledEventStore"; export * from "./GuildStore"; @@ -39,6 +41,7 @@ export * from "./InviteStore"; export * from "./JoinedThreadsStore"; export * from "./LocaleStore"; export * from "./MediaEngineStore"; +export * from "./MessageRequestStore"; export * from "./MessageStore"; export * from "./NotificationSettingsStore"; export * from "./OverridePremiumTypeStore"; @@ -56,6 +59,7 @@ export * from "./RunningGameStore"; export * from "./SafetyHubStore"; export * from "./SelectedChannelStore"; export * from "./SelectedGuildStore"; +export * from "./SelfPresenceStore"; export * from "./SessionsStore"; export * from "./SortedGuildStore"; export * from "./SoundboardStore"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8aeb73736..172896717 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,153 +7,153 @@ importers: configDependencies: {} packageManagerDependencies: pnpm: - specifier: 12.5.1 - version: 12.5.1 + specifier: 12.6.0 + version: 12.6.0 packages: - '@pnpm/exe.android-arm64@12.5.1': - resolution: {integrity: sha512-6LGBmQuDzUmgpHSuy+haG0jrmkwFNa4EuShDZqK3cIBv4Wfb75CzjJmowkzr+iJg40vnBKMQ62t4Ko6mwsId7A==} + '@pnpm/exe.android-arm64@12.6.0': + resolution: {integrity: sha512-kviIHft9h02q+7N2In7tSL9T/HRUSGwYmU74YPtsWU5ee7vgqPyC0JT6RRX6miW+NxX1CvHgQxg69qq1qTLJYQ==} cpu: [arm64] os: [android] - '@pnpm/exe.android-x64@12.5.1': - resolution: {integrity: sha512-091oCltP3Rx89yxL1Wh5rXkUXEyFzyxIzSHKRFDyDFlQkb8Ox8FaDcm+M8PNkMyqnLA+qeGOLzY7Rjj9izl1Ww==} + '@pnpm/exe.android-x64@12.6.0': + resolution: {integrity: sha512-CT8aJKLq2mtZFE71pr4E5Z2xHL8uGnRGr+NclDqsXlVF4SVcQ2QAs14mWi0C8gjT4hbmi+Q0lJRRIkMAWfjjng==} cpu: [x64] os: [android] - '@pnpm/exe.darwin-arm64@12.5.1': - resolution: {integrity: sha512-r1vEMQPVjRexZMyL2HonxJoo3+nuB/+G+tg+f2PK6faRdXX1TDwevKXOxJAfqlPInTy6W/pm912+s+m0NcR4BQ==} + '@pnpm/exe.darwin-arm64@12.6.0': + resolution: {integrity: sha512-rafpVkjzugKBMxSvGQd5wK1x5eOTkD/+lcJIFHeQhvd+BJ8kDisOOvwhQDrpGd4vd2Fx+hhW0P2Ptt638OlhFg==} cpu: [arm64] os: [darwin] - '@pnpm/exe.darwin-x64@12.5.1': - resolution: {integrity: sha512-YHwI1g2B+Y2cAEylOR31r781GWijdJL7Gy7TEn/ZpZ5v/Cuwp5/Pz0EFCgo0M2MKLafAbL/laUMGvOpAdnerAw==} + '@pnpm/exe.darwin-x64@12.6.0': + resolution: {integrity: sha512-72Jpuv1m24gI8zUNcaylYpBWEhBzz1VPhnDIU2GYM2eRP+KsOqVLwV78i+JrihI39zY2NNXmaN4eAKX1inpaDQ==} cpu: [x64] os: [darwin] - '@pnpm/exe.freebsd-x64@12.5.1': - resolution: {integrity: sha512-sFUMHiYFs6q5syFwgaVppzhQSmqnXoJIz/YwTXIOXTDE76ndIpTRpDGAnBCBKjsaEBnqjJA/2l6hpJcNDNoMiA==} + '@pnpm/exe.freebsd-x64@12.6.0': + resolution: {integrity: sha512-LON4QgNy1w/XF4uySZIyC/5hEB0oGdelXsY9tSKqstER+2j2X2oHz67skD11RRd/HWFRtMr64shQZ4I9ZoZ0zg==} cpu: [x64] os: [freebsd] - '@pnpm/exe.linux-arm64-musl@12.5.1': - resolution: {integrity: sha512-zupuxYZBuBEGjUz805/4/Asq01UNziFADANt8yp+LdUjU9bbMa3xY78Bx1PsGDqBy7aiad4sdUMK8ZxH4n4gmQ==} + '@pnpm/exe.linux-arm64-musl@12.6.0': + resolution: {integrity: sha512-BdDpX+DeaMUc5x6WNcE6FkmFy36NwrBbBvwsZU737Zt3u1fTY+iKFPchjEQNCM4rT6q6xvF2oN3ZwExGsJCkxQ==} cpu: [arm64] os: [linux] libc: [musl] - '@pnpm/exe.linux-arm64@12.5.1': - resolution: {integrity: sha512-6hbMWW2/eQo1b5wvQPe/ndLHVTH88Rav6N+ffD4/h6IuFMjWCgasFYYsFv0GrvpqREAx3SwmZSvli+0NFXqbxA==} + '@pnpm/exe.linux-arm64@12.6.0': + resolution: {integrity: sha512-8h2sNoIhHDpHDYqZZCh9PXr6krqW10btb0GHVGuw710muDHlFAHMtUG2ogmaHge6zJG1xgY4Y7mwX5g/LWvrYg==} cpu: [arm64] os: [linux] libc: [glibc] - '@pnpm/exe.linux-ppc64@12.5.1': - resolution: {integrity: sha512-Gg3maDzaE/ZFMV9HIx/BwMN0Y6QbEs13URfxmiYHtKjjLAs5wEQZRMUP87YNLYO7cNaEfbM8GRbS9vPosyD9Gw==} + '@pnpm/exe.linux-ppc64@12.6.0': + resolution: {integrity: sha512-ld6xgcEhFCFrsVsJhbmdmR714PnsEspO/Ij8w0/D7OSiz2hYGu3fZd5tKRxOI5m6H6Gl0/RRFAPncTHbsgXVjQ==} cpu: [ppc64] os: [linux] libc: [glibc] - '@pnpm/exe.linux-riscv64@12.5.1': - resolution: {integrity: sha512-6fgWxXYMBMsWQ8DAiRevscX4QZQjwh+FsyCj8ZOk8pMXvqeq84MqBLCmS6KckvnbdqJ+HlSVQ7fs/kd0ldwfhA==} + '@pnpm/exe.linux-riscv64@12.6.0': + resolution: {integrity: sha512-HIbImydoC3J8NFt+8MXfhTCf5rO6NjCMyinSAHac0VmV8uCHw+kbQkyAzxV84rzz9ZOzmBOnj0b1N461UIYGsw==} cpu: [riscv64] os: [linux] libc: [glibc] - '@pnpm/exe.linux-s390x@12.5.1': - resolution: {integrity: sha512-nzMZruRvxDhEfYUhzu+7EmM39+82Dgagc/6hPFPqGqzXNGcIG0anuxbUxfeNtI64SHt91KuuYUmCB/inlM+Pag==} + '@pnpm/exe.linux-s390x@12.6.0': + resolution: {integrity: sha512-DjSqT7+BZ/lWcDHwNMuzsRVfyxUimh+D54Xw4tSWbdVVQhtWtNMUyI93LVnwCmsoEpar2gC3SFeAgywx37svKQ==} cpu: [s390x] os: [linux] libc: [glibc] - '@pnpm/exe.linux-x64-musl@12.5.1': - resolution: {integrity: sha512-kHCbegdTNHpzmPtUD4S5fqkVkqgdQR47spF9p2VPP3dIIkZl6Ytk8w0vhlAsAGgge8FmucfwX+vvPKgm0NtOCQ==} + '@pnpm/exe.linux-x64-musl@12.6.0': + resolution: {integrity: sha512-31lKeGPmRE6xfV6I3VjaEGVFRei14pl/zgoFDK4w+UkbJqOuNl2Ht3O1GuqNIg3Gl14qTEb4kZRAYFHXifDx9A==} cpu: [x64] os: [linux] libc: [musl] - '@pnpm/exe.linux-x64@12.5.1': - resolution: {integrity: sha512-3PkUBYo5z4dgtlnTNIFj7QGpcDUAuqXz9WGVigPDCeccEnhGiRkWmA5102TmYJHtwJP3LfmE+ZF9PGeWhn8p9Q==} + '@pnpm/exe.linux-x64@12.6.0': + resolution: {integrity: sha512-qFWBneHJAJ73W4whtbaFOL1M/7DBC6ILHXuxc7ZPtEhfPuT1zeZiGrmKHoMAfJA+mcm6xhOFljqVTUS+00Jabw==} cpu: [x64] os: [linux] libc: [glibc] - '@pnpm/exe.win32-arm64@12.5.1': - resolution: {integrity: sha512-49NvjZIXHly56/PLoEDD7VphbO4N8dwMXoApElDFCpVGDNGeKlwlib1tXtnpTF6i2/XIsAj7GgatHB5KHXgBnA==} + '@pnpm/exe.win32-arm64@12.6.0': + resolution: {integrity: sha512-OhfefXEEykZlslSUhR8PPRe6MVPV3Oink/dVfIecE5velpc7j80cZYsHlaDrtRDcm3TPwQHkaRW1SJ1efX9oFg==} cpu: [arm64] os: [win32] - '@pnpm/exe.win32-x64@12.5.1': - resolution: {integrity: sha512-ePUmQFPAPJFNMwg1lelDx2PdjHqYRiF0yfg5e6qeDbPNOu97QNo557Ru/SxmCrmt8ydQWNuZXWpdEp019md5vw==} + '@pnpm/exe.win32-x64@12.6.0': + resolution: {integrity: sha512-L2tuyrD2+Imgxs3VK/ST/2L3xD6vDP0ktJQxM0TaGw7TbAQEMq+RMc8iK6Ew7Id579uzjJe8jSfJID2ZGsOHCA==} cpu: [x64] os: [win32] - pnpm@12.5.1: - resolution: {integrity: sha512-4/MFvHhKK8ifWtO2E4iJRw+ujSr182thIW7JHCw9ZAiXdfneOKrDMQROpA8kXLDVZmOS399lgk4ZB+9qLGLeXw==} + pnpm@12.6.0: + resolution: {integrity: sha512-PvaPlRyxEawgS0paFvCy3fDaVqluBBPoHYVdnwtV75JnFHCQKOHNAMQFwsX7e56OxNxGd3yAXQNzwvL/AP0g7A==} engines: {node: '>=18.*'} hasBin: true snapshots: - '@pnpm/exe.android-arm64@12.5.1': + '@pnpm/exe.android-arm64@12.6.0': optional: true - '@pnpm/exe.android-x64@12.5.1': + '@pnpm/exe.android-x64@12.6.0': optional: true - '@pnpm/exe.darwin-arm64@12.5.1': + '@pnpm/exe.darwin-arm64@12.6.0': optional: true - '@pnpm/exe.darwin-x64@12.5.1': + '@pnpm/exe.darwin-x64@12.6.0': optional: true - '@pnpm/exe.freebsd-x64@12.5.1': + '@pnpm/exe.freebsd-x64@12.6.0': optional: true - '@pnpm/exe.linux-arm64-musl@12.5.1': + '@pnpm/exe.linux-arm64-musl@12.6.0': optional: true - '@pnpm/exe.linux-arm64@12.5.1': + '@pnpm/exe.linux-arm64@12.6.0': optional: true - '@pnpm/exe.linux-ppc64@12.5.1': + '@pnpm/exe.linux-ppc64@12.6.0': optional: true - '@pnpm/exe.linux-riscv64@12.5.1': + '@pnpm/exe.linux-riscv64@12.6.0': optional: true - '@pnpm/exe.linux-s390x@12.5.1': + '@pnpm/exe.linux-s390x@12.6.0': optional: true - '@pnpm/exe.linux-x64-musl@12.5.1': + '@pnpm/exe.linux-x64-musl@12.6.0': optional: true - '@pnpm/exe.linux-x64@12.5.1': + '@pnpm/exe.linux-x64@12.6.0': optional: true - '@pnpm/exe.win32-arm64@12.5.1': + '@pnpm/exe.win32-arm64@12.6.0': optional: true - '@pnpm/exe.win32-x64@12.5.1': + '@pnpm/exe.win32-x64@12.6.0': optional: true - pnpm@12.5.1: + pnpm@12.6.0: optionalDependencies: - '@pnpm/exe.android-arm64': 12.5.1 - '@pnpm/exe.android-x64': 12.5.1 - '@pnpm/exe.darwin-arm64': 12.5.1 - '@pnpm/exe.darwin-x64': 12.5.1 - '@pnpm/exe.freebsd-x64': 12.5.1 - '@pnpm/exe.linux-arm64': 12.5.1 - '@pnpm/exe.linux-arm64-musl': 12.5.1 - '@pnpm/exe.linux-ppc64': 12.5.1 - '@pnpm/exe.linux-riscv64': 12.5.1 - '@pnpm/exe.linux-s390x': 12.5.1 - '@pnpm/exe.linux-x64': 12.5.1 - '@pnpm/exe.linux-x64-musl': 12.5.1 - '@pnpm/exe.win32-arm64': 12.5.1 - '@pnpm/exe.win32-x64': 12.5.1 + '@pnpm/exe.android-arm64': 12.6.0 + '@pnpm/exe.android-x64': 12.6.0 + '@pnpm/exe.darwin-arm64': 12.6.0 + '@pnpm/exe.darwin-x64': 12.6.0 + '@pnpm/exe.freebsd-x64': 12.6.0 + '@pnpm/exe.linux-arm64': 12.6.0 + '@pnpm/exe.linux-arm64-musl': 12.6.0 + '@pnpm/exe.linux-ppc64': 12.6.0 + '@pnpm/exe.linux-riscv64': 12.6.0 + '@pnpm/exe.linux-s390x': 12.6.0 + '@pnpm/exe.linux-x64': 12.6.0 + '@pnpm/exe.linux-x64-musl': 12.6.0 + '@pnpm/exe.win32-arm64': 12.6.0 + '@pnpm/exe.win32-x64': 12.6.0 --- lockfileVersion: '9.0' diff --git a/src/equicordplugins/randomVoice/index.tsx b/src/equicordplugins/randomVoice/index.tsx index 184ae2645..d586990db 100644 --- a/src/equicordplugins/randomVoice/index.tsx +++ b/src/equicordplugins/randomVoice/index.tsx @@ -16,12 +16,11 @@ import { Devs, EquicordDevs, IS_MAC } from "@utils/constants"; import { classNameFactory } from "@utils/css"; import definePlugin, { makeRange, OptionType } from "@utils/types"; import type { Channel, VoiceState } from "@vencord/discord-types"; -import { findByCodeLazy, findByPropsLazy } from "@webpack"; +import { findByCodeLazy } from "@webpack"; import { ChannelActions, ChannelRouter, ChannelStore, ContextMenuApi, FluxDispatcher, GuildStore, MediaEngineStore, Menu, PermissionsBits, PermissionStore, React, RelationshipStore, SelectedChannelStore, Toasts, useEffect, UserStore, useState, VoiceActions, VoiceStateStore } from "@webpack/common"; const startStream = findByCodeLazy('type:"STREAM_START"'); const getDesktopSources = findByCodeLazy("desktop sources"); -const { isVideoEnabled } = findByPropsLazy("isVideoEnabled"); const NO_SERVERS = "__NONE__"; const DEFAULT_KEYBIND = IS_MAC ? ["Meta", "Shift", "R"] : ["Control", "Shift", "R"]; const MODIFIER_KEYS = new Set(["control", "ctrl", "shift", "alt", "option", "meta", "cmd", "command", "mod"]); @@ -546,7 +545,7 @@ function pickRandomChannel(store = settings.store) { } async function enableCamera() { - if (isVideoEnabled()) return; + if (MediaEngineStore.isVideoEnabled()) return; FluxDispatcher.dispatch({ type: "MEDIA_ENGINE_SET_VIDEO_ENABLED", diff --git a/src/equicordplugins/richPresence/services/statsfm.ts b/src/equicordplugins/richPresence/services/statsfm.ts index f69f5a908..809484f01 100644 --- a/src/equicordplugins/richPresence/services/statsfm.ts +++ b/src/equicordplugins/richPresence/services/statsfm.ts @@ -7,8 +7,7 @@ import { Logger } from "@utils/Logger"; import { Activity, ActivityButton } from "@vencord/discord-types"; import { ActivityFlags, ActivityType } from "@vencord/discord-types/enums"; -import { findByPropsLazy } from "@webpack"; -import { ApplicationAssetUtils, FluxDispatcher } from "@webpack/common"; +import { ApplicationAssetUtils, FluxDispatcher, SelfPresenceStore } from "@webpack/common"; import { settings } from "../settings"; import { NameFormat } from "../types"; @@ -18,7 +17,6 @@ const APPLICATION_ID = "1325126169179197500"; const PLACEHOLDER_ID = "2a96cbd8b46e442fc41c2b86b821562f"; const SOCKET_ID = "RichPresence_SFM"; const logger = new Logger("RichPresence:StatsFm"); -const PresenceStore = findByPropsLazy("getLocalPresence"); let updateInterval: NodeJS.Timeout | undefined; @@ -67,11 +65,11 @@ function getLargeImage(track: SfmTrackData): string | undefined { async function getActivity(): Promise { if (settings.store.sfm_hideWithExternalRPC) { - if (PresenceStore.getActivities().some(a => a.application_id !== APPLICATION_ID)) return null; + if (SelfPresenceStore.getActivities().some(a => a.application_id !== APPLICATION_ID)) return null; } if (settings.store.sfm_hideWithSpotify) { - if (PresenceStore.getActivities().some(a => a.type === ActivityType.LISTENING && a.application_id !== APPLICATION_ID)) + if (SelfPresenceStore.getActivities().some(a => a.type === ActivityType.LISTENING && a.application_id !== APPLICATION_ID)) return null; } diff --git a/src/equicordplugins/toggleVideoBind/index.ts b/src/equicordplugins/toggleVideoBind/index.ts index 323a1e771..f1a4f8b03 100644 --- a/src/equicordplugins/toggleVideoBind/index.ts +++ b/src/equicordplugins/toggleVideoBind/index.ts @@ -7,8 +7,7 @@ import { definePluginSettings } from "@api/Settings"; import { EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy } from "@webpack"; -import { FluxDispatcher } from "@webpack/common"; +import { FluxDispatcher, MediaEngineStore } from "@webpack/common"; const validKeycodes = [ "Backspace", "Tab", "Enter", "ShiftLeft", "ShiftRight", "ControlLeft", "ControlRight", "AltLeft", "AltRight", "Pause", "CapsLock", @@ -44,15 +43,13 @@ const settings = definePluginSettings({ }, }); -const { isVideoEnabled } = findByPropsLazy("isVideoEnabled"); - function handleKeydown({ code, ctrlKey, shiftKey, altKey }: KeyboardEvent) { const { keyBind, reqCtrl, reqShift, reqAlt } = settings.store; if (keyBind !== code || ctrlKey !== reqCtrl || shiftKey !== reqShift || altKey !== reqAlt) { return; } // please don't think about it FluxDispatcher.dispatch({ type: "MEDIA_ENGINE_SET_VIDEO_ENABLED", - enabled: !isVideoEnabled(), + enabled: !MediaEngineStore.isVideoEnabled(), }); } diff --git a/src/plugins/noPendingCount/index.ts b/src/plugins/noPendingCount/index.ts index 5bede8b49..bca00ef73 100644 --- a/src/plugins/noPendingCount/index.ts +++ b/src/plugins/noPendingCount/index.ts @@ -19,9 +19,7 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy } from "@webpack"; - -const MessageRequestStore = findByPropsLazy("getMessageRequestsCount"); +import { MessageRequestStore } from "@webpack/common"; const settings = definePluginSettings({ hideFriendRequestsCount: { diff --git a/src/plugins/tenorGifSearch/index.tsx b/src/plugins/tenorGifSearch/index.tsx index 2b6ea1a56..a6987af3c 100644 --- a/src/plugins/tenorGifSearch/index.tsx +++ b/src/plugins/tenorGifSearch/index.tsx @@ -7,14 +7,11 @@ import { Devs } from "@utils/constants"; import { isNonNullish } from "@utils/guards"; import definePlugin from "@utils/types"; -import { findStoreLazy } from "@webpack"; -import { FluxDispatcher, LocaleStore } from "@webpack/common"; +import { FluxDispatcher, GIFPickerViewStore, LocaleStore } from "@webpack/common"; // API key is taken from the GBoard app on iOS const TENOR_KEY = "3Z0688EVWYKH"; -const GIFPickerViewStore = findStoreLazy("GIFPickerViewStore"); - let cachedCategories: TrendingCategories | null = null; interface TenorMedia { diff --git a/src/plugins/webPWA.browser/index.tsx b/src/plugins/webPWA.browser/index.tsx index 452d2c6f4..3785c6deb 100644 --- a/src/plugins/webPWA.browser/index.tsx +++ b/src/plugins/webPWA.browser/index.tsx @@ -8,14 +8,10 @@ import { addThemeChangeListener, removeThemeChangeListener } from "@api/Themes"; import { Devs } from "@utils/constants"; import { sleep } from "@utils/misc"; import definePlugin from "@utils/types"; -import { FluxStore } from "@vencord/discord-types"; -import { findStoreLazy } from "@webpack"; -import { NotificationSettingsStore, RelationshipStore, ThemeStore } from "@webpack/common"; +import { GuildReadStateStore, NotificationSettingsStore, RelationshipStore, ThemeStore } from "@webpack/common"; import managedStyle from "./styles.css?managed"; -const GuildReadStateStore: FluxStore & { getTotalMentionCount: () => number; hasAnyUnread: () => boolean; } = findStoreLazy("GuildReadStateStore"); - let _keybinds: Record any; }>; function colorToHex(color: string) { diff --git a/src/webpack/common/stores.ts b/src/webpack/common/stores.ts index cad9a0aec..ad530c159 100644 --- a/src/webpack/common/stores.ts +++ b/src/webpack/common/stores.ts @@ -110,6 +110,10 @@ export let UserGuildJoinRequestStore: t.UserGuildJoinRequestStore; export let BasicGuildStore: t.BasicGuildStore; export let GuildProfileStore: t.GuildProfileStore; export let ChannelAffinitiesStore: t.ChannelAffinitiesStore; +export let SelfPresenceStore: t.SelfPresenceStore; +export let MessageRequestStore: t.MessageRequestStore; +export let GIFPickerViewStore: t.GIFPickerViewStore; +export let GuildReadStateStore: t.GuildReadStateStore; /** * @see jsdoc of {@link t.useStateFromStores} @@ -191,6 +195,10 @@ waitForStore("UserGuildJoinRequestStore", m => UserGuildJoinRequestStore = m); waitForStore("BasicGuildStore", m => BasicGuildStore = m); waitForStore("GuildProfileStore", m => GuildProfileStore = m); waitForStore("ChannelAffinitiesV2Store", m => ChannelAffinitiesStore = m); +waitForStore("SelfPresenceStore", m => SelfPresenceStore = m); +waitForStore("MessageRequestStore", m => MessageRequestStore = m); +waitForStore("GIFPickerViewStore", m => GIFPickerViewStore = m); +waitForStore("GuildReadStateStore", m => GuildReadStateStore = m); waitForStore("ThemeStore", m => { ThemeStore = m; // Importing this directly causes all webpack commons to be imported, which can easily cause circular dependencies.