From 80b738ff3e9418aa950027a503aaa7672d83677b Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 4 May 2024 21:15:14 -0300 Subject: [PATCH 1/6] Future proof FakeNitro and Experiments to not brick Discord startup --- src/plugins/experiments/index.tsx | 17 +++++++++--- src/plugins/fakeNitro/index.tsx | 44 +++++++++++++++++-------------- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/plugins/experiments/index.tsx b/src/plugins/experiments/index.tsx index 34463882..50b9521f 100644 --- a/src/plugins/experiments/index.tsx +++ b/src/plugins/experiments/index.tsx @@ -20,10 +20,12 @@ import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { ErrorCard } from "@components/ErrorCard"; import { Devs } from "@utils/constants"; +import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; -import { Forms, React } from "@webpack/common"; +import { Forms, React, UserStore } from "@webpack/common"; +import { User } from "discord-types/general"; const KbdStyles = findByPropsLazy("key", "removeBuildOverride"); @@ -68,8 +70,8 @@ export default definePlugin({ predicate: () => settings.store.enableIsStaff, replacement: [ { - match: /=>*?(\i)\.hasFlag\((\i\.\i)\.STAFF\)}/, - replace: (_, user, flags) => `=>Vencord.Webpack.Common.UserStore.getCurrentUser()?.id===${user}.id||${user}.hasFlag(${flags}.STAFF)}` + match: /(?<=>)(\i)\.hasFlag\((\i\.\i)\.STAFF\)(?=})/, + replace: (_, user, flags) => `$self.isStaff(${user},${flags})` }, { match: /hasFreePremium\(\){return this.isStaff\(\)\s*?\|\|/, @@ -86,6 +88,15 @@ export default definePlugin({ } ], + isStaff(user: User, flags: any) { + try { + return UserStore.getCurrentUser()?.id === user.id || user.hasFlag(flags.STAFF); + } catch (err) { + new Logger("Experiments").error(err); + return user.hasFlag(flags.STAFF); + } + }, + settingsAboutComponent: () => { const isMacOS = navigator.platform.includes("Mac"); const modKey = isMacOS ? "cmd" : "ctrl"; diff --git a/src/plugins/fakeNitro/index.tsx b/src/plugins/fakeNitro/index.tsx index adf1f70f..90ce10f6 100644 --- a/src/plugins/fakeNitro/index.tsx +++ b/src/plugins/fakeNitro/index.tsx @@ -413,31 +413,35 @@ export default definePlugin({ }, handleProtoChange(proto: any, user: any) { - if (proto == null || typeof proto === "string" || !UserSettingsProtoStore || !PreloadedUserSettingsActionCreators || !AppearanceSettingsActionCreators || !ClientThemeSettingsActionsCreators) return; + try { + if (proto == null || typeof proto === "string") return; - const premiumType: number = user?.premium_type ?? UserStore?.getCurrentUser()?.premiumType ?? 0; + const premiumType: number = user?.premium_type ?? UserStore?.getCurrentUser()?.premiumType ?? 0; - if (premiumType !== 2) { - proto.appearance ??= AppearanceSettingsActionCreators.create(); + if (premiumType !== 2) { + proto.appearance ??= AppearanceSettingsActionCreators.create(); - if (UserSettingsProtoStore.settings.appearance?.theme != null) { - const appearanceSettingsDummy = AppearanceSettingsActionCreators.create({ - theme: UserSettingsProtoStore.settings.appearance.theme - }); + if (UserSettingsProtoStore.settings.appearance?.theme != null) { + const appearanceSettingsDummy = AppearanceSettingsActionCreators.create({ + theme: UserSettingsProtoStore.settings.appearance.theme + }); - proto.appearance.theme = appearanceSettingsDummy.theme; - } - - if (UserSettingsProtoStore.settings.appearance?.clientThemeSettings?.backgroundGradientPresetId?.value != null) { - const clientThemeSettingsDummy = ClientThemeSettingsActionsCreators.create({ - backgroundGradientPresetId: { - value: UserSettingsProtoStore.settings.appearance.clientThemeSettings.backgroundGradientPresetId.value - } - }); - - proto.appearance.clientThemeSettings ??= clientThemeSettingsDummy; - proto.appearance.clientThemeSettings.backgroundGradientPresetId = clientThemeSettingsDummy.backgroundGradientPresetId; + proto.appearance.theme = appearanceSettingsDummy.theme; + } + + if (UserSettingsProtoStore.settings.appearance?.clientThemeSettings?.backgroundGradientPresetId?.value != null) { + const clientThemeSettingsDummy = ClientThemeSettingsActionsCreators.create({ + backgroundGradientPresetId: { + value: UserSettingsProtoStore.settings.appearance.clientThemeSettings.backgroundGradientPresetId.value + } + }); + + proto.appearance.clientThemeSettings ??= clientThemeSettingsDummy; + proto.appearance.clientThemeSettings.backgroundGradientPresetId = clientThemeSettingsDummy.backgroundGradientPresetId; + } } + } catch (err) { + new Logger("FakeNitro").error(err); } }, From a525cd0113b37fbe08512a6e68ecb62b8d74cd72 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sun, 5 May 2024 03:59:57 +0200 Subject: [PATCH 2/6] bump to v1.8.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1a0a4322..ae4336d3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.8.0", + "version": "1.8.1", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": { From b3819228eddd276ae88d14faa63aa5304d6ac518 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 4 May 2024 23:15:33 -0300 Subject: [PATCH 3/6] Resolve PluginSettings circular deps better --- src/components/PluginSettings/index.tsx | 5 +++-- src/plugins/_api/badges/index.tsx | 8 ++------ src/plugins/_core/settings.tsx | 23 +++++++++++++++-------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index 33a472c1..e6b2cf1f 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -27,6 +27,7 @@ import PluginModal from "@components/PluginSettings/PluginModal"; import { AddonCard } from "@components/VencordSettings/AddonCard"; import { SettingsTab } from "@components/VencordSettings/shared"; import { ChangeList } from "@utils/ChangeList"; +import { proxyLazy } from "@utils/lazy"; import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; import { classes, isObjectEmpty } from "@utils/misc"; @@ -38,8 +39,8 @@ import { Alerts, Button, Card, Forms, lodash, Parser, React, Select, Text, TextI import Plugins from "~plugins"; -import { startDependenciesRecursive, startPlugin, stopPlugin } from "../../plugins"; - +// Avoid circular dependency +const { startDependenciesRecursive, startPlugin, stopPlugin } = proxyLazy(() => require("../../plugins")); const cl = classNameFactory("vc-plugins-"); const logger = new Logger("PluginSettings", "#a6d189"); diff --git a/src/plugins/_api/badges/index.tsx b/src/plugins/_api/badges/index.tsx index 5493d4b6..bbccf0a1 100644 --- a/src/plugins/_api/badges/index.tsx +++ b/src/plugins/_api/badges/index.tsx @@ -23,6 +23,7 @@ import DonateButton from "@components/DonateButton"; import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { Heart } from "@components/Heart"; +import { openContributorModal } from "@components/PluginSettings/ContributorModal"; import { Devs } from "@utils/constants"; import { Margins } from "@utils/margins"; import { isPluginDev } from "@utils/misc"; @@ -37,12 +38,7 @@ const ContributorBadge: ProfileBadge = { image: CONTRIBUTOR_BADGE, position: BadgePosition.START, shouldShow: ({ user }) => isPluginDev(user.id), - onClick(_, { user }) { - // circular import shenanigans - const { openContributorModal } = require("@components/PluginSettings/ContributorModal") as typeof import("@components/PluginSettings/ContributorModal"); - // setImmediate is needed to run on later tick to workaround limitation in proxyLazy - setImmediate(() => openContributorModal(user)); - } + onClick: (_, { user }) => openContributorModal(user) }; let DonorBadges = {} as Record>>; diff --git a/src/plugins/_core/settings.tsx b/src/plugins/_core/settings.tsx index 1aea0d6e..772ee9b6 100644 --- a/src/plugins/_core/settings.tsx +++ b/src/plugins/_core/settings.tsx @@ -17,6 +17,13 @@ */ import { Settings } from "@api/Settings"; +import BackupAndRestoreTab from "@components/VencordSettings/BackupAndRestoreTab"; +import CloudTab from "@components/VencordSettings/CloudTab"; +import PatchHelperTab from "@components/VencordSettings/PatchHelperTab"; +import PluginsTab from "@components/VencordSettings/PluginsTab"; +import ThemesTab from "@components/VencordSettings/ThemesTab"; +import UpdaterTab from "@components/VencordSettings/UpdaterTab"; +import VencordTab from "@components/VencordSettings/VencordTab"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { React } from "@webpack/common"; @@ -36,7 +43,7 @@ export default definePlugin({ match: /\[\(0,.{1,3}\.jsxs?\)\((.{1,10}),(\{[^{}}]+\{.{0,20}.versionHash,.+?\})\)," "/, replace: (m, component, props) => { props = props.replace(/children:\[.+\]/, ""); - return `${m},Vencord.Plugins.plugins.Settings.makeInfoElements(${component}, ${props})`; + return `${m},$self.makeInfoElements(${component}, ${props})`; } } ] @@ -77,43 +84,43 @@ export default definePlugin({ { section: "VencordSettings", label: "Vencord", - element: require("@components/VencordSettings/VencordTab").default, + element: VencordTab, className: "vc-settings" }, { section: "VencordPlugins", label: "Plugins", - element: require("@components/VencordSettings/PluginsTab").default, + element: PluginsTab, className: "vc-plugins" }, { section: "VencordThemes", label: "Themes", - element: require("@components/VencordSettings/ThemesTab").default, + element: ThemesTab, className: "vc-themes" }, !IS_UPDATER_DISABLED && { section: "VencordUpdater", label: "Updater", - element: require("@components/VencordSettings/UpdaterTab").default, + element: UpdaterTab, className: "vc-updater" }, { section: "VencordCloud", label: "Cloud", - element: require("@components/VencordSettings/CloudTab").default, + element: CloudTab, className: "vc-cloud" }, { section: "VencordSettingsSync", label: "Backup & Restore", - element: require("@components/VencordSettings/BackupAndRestoreTab").default, + element: BackupAndRestoreTab, className: "vc-backup-restore" }, IS_DEV && { section: "VencordPatchHelper", label: "Patch Helper", - element: require("@components/VencordSettings/PatchHelperTab").default, + element: PatchHelperTab, className: "vc-patch-helper" }, ...this.customSections.map(func => func(SectionTypes)), From bc68bc0312b438df391c896ef71fdda9f5204fe2 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sat, 4 May 2024 23:15:46 -0300 Subject: [PATCH 4/6] ImplicitRelationships: Properly test find --- src/plugins/implicitRelationships/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/implicitRelationships/index.ts b/src/plugins/implicitRelationships/index.ts index 15165d64..4faad2a9 100644 --- a/src/plugins/implicitRelationships/index.ts +++ b/src/plugins/implicitRelationships/index.ts @@ -19,11 +19,12 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByProps, findStoreLazy } from "@webpack"; +import { findByPropsLazy, findStoreLazy } from "@webpack"; import { ChannelStore, FluxDispatcher, GuildStore, RelationshipStore, SnowflakeUtils, UserStore } from "@webpack/common"; import { Settings } from "Vencord"; const UserAffinitiesStore = findStoreLazy("UserAffinitiesStore"); +const { FriendsSections } = findByPropsLazy("FriendsSections"); interface UserAffinity { user_id: string; @@ -181,7 +182,6 @@ export default definePlugin({ }, start() { - const { FriendsSections } = findByProps("FriendsSections"); FriendsSections.IMPLICIT = "IMPLICIT"; } }); From b98544ed1f93579dd04ab681de9fb8de17b8dc17 Mon Sep 17 00:00:00 2001 From: Fafa <87046111+Faf4a@users.noreply.github.com> Date: Sun, 5 May 2024 06:42:15 +0200 Subject: [PATCH 5/6] ReviewDB: Fix context menus being added to folders (#2416) --- src/plugins/reviewDB/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index bcd0f163..e73bce82 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -36,6 +36,7 @@ import { settings } from "./settings"; import { showToast } from "./utils"; const guildPopoutPatch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild, onClose(): void; }) => { + if (!guild) return; children.push( Date: Sun, 5 May 2024 20:15:01 +1200 Subject: [PATCH 6/6] ImageLink: Fix embed showing in gifs (#2417) --- src/plugins/imageLink/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/imageLink/index.ts b/src/plugins/imageLink/index.ts index 73a977fa..5e8dd23e 100644 --- a/src/plugins/imageLink/index.ts +++ b/src/plugins/imageLink/index.ts @@ -10,15 +10,15 @@ import definePlugin from "@utils/types"; export default definePlugin({ name: "ImageLink", description: "Never hide image links in messages, even if it's the only content", - authors: [Devs.Kyuuhachi], + authors: [Devs.Kyuuhachi, Devs.Sqaaakoi], patches: [ { - find: "isEmbedInline:function()", + find: "unknownUserMentionPlaceholder:", replacement: { - match: /(?<=isEmbedInline:function\(\)\{return )\i(?=\})/, - replace: "()=>false", - }, - }, - ], + match: /\(0,\i\.isEmbedInline\)\(\i\)/, + replace: "false", + } + } + ] });