diff options
author | 1024x2 | 2024-06-13 00:59:55 +0100 |
---|---|---|
committer | 1024x2 | 2024-06-13 00:59:55 +0100 |
commit | 72fcbfd119290775e57739e1e9e65ab7be431443 (patch) | |
tree | ffb079e71d46e0dbe0040626ee96d8c9dfce49ba /0003-Experiments-Re-add-isStaff-and-staging-banner.patch | |
parent | e6d44d95d2ee68fe054eecc6599273e8e029d8b8 (diff) |
Update patches
Diffstat (limited to '0003-Experiments-Re-add-isStaff-and-staging-banner.patch')
-rw-r--r-- | 0003-Experiments-Re-add-isStaff-and-staging-banner.patch | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/0003-Experiments-Re-add-isStaff-and-staging-banner.patch b/0003-Experiments-Re-add-isStaff-and-staging-banner.patch deleted file mode 100644 index de147c7..0000000 --- a/0003-Experiments-Re-add-isStaff-and-staging-banner.patch +++ /dev/null @@ -1,109 +0,0 @@ -From 3b8d2305b7f49f24b2b82d3bff35ce5aebbcc7fb Mon Sep 17 00:00:00 2001 -From: 1024x2 <2pow11@gmail.com> -Date: Sat, 8 Jun 2024 23:11:43 +0100 -Subject: [PATCH 3/6] Experiments: Re-add isStaff and staging banner - -(it's funny) ---- - src/plugins/experiments/index.tsx | 54 +++++++++++++++++++++++++++++-- - 1 file changed, 52 insertions(+), 2 deletions(-) - -diff --git a/src/plugins/experiments/index.tsx b/src/plugins/experiments/index.tsx -index cf4dbf24..5a01ffad 100644 ---- a/src/plugins/experiments/index.tsx -+++ b/src/plugins/experiments/index.tsx -@@ -16,19 +16,37 @@ - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -+import { definePluginSettings } from "@api/Settings"; - import { disableStyle, enableStyle } from "@api/Styles"; - 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 from "@utils/types"; -+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"; - - import hideBugReport from "./hideBugReport.css?managed"; - - const KbdStyles = findByPropsLazy("key", "removeBuildOverride"); - -+const settings = definePluginSettings({ -+ enableIsStaff: { -+ description: "Enable isStaff", -+ type: OptionType.BOOLEAN, -+ default: false, -+ restartNeeded: true -+ }, -+ forceStagingBanner: { -+ description: "Whether to force Staging banner under user area.", -+ type: OptionType.BOOLEAN, -+ default: false, -+ restartNeeded: true -+ } -+}); -+ - export default definePlugin({ - name: "Experiments", - description: "Enable Access to Experiments & other dev-only features in Discord!", -@@ -39,6 +57,7 @@ export default definePlugin({ - Devs.BanTheNons, - Devs.Nuckyz - ], -+ settings, - - patches: [ - { -@@ -69,12 +88,43 @@ export default definePlugin({ - match: /\i\.isStaff\(\)/, - replace: "true" - } -+ }, -+ { -+ find: '"isStaff",', -+ predicate: () => settings.store.enableIsStaff, -+ replacement: [ -+ { -+ match: /(?<=>)(\i)\.hasFlag\((\i\.\i)\.STAFF\)(?=})/, -+ replace: (_, user, flags) => `$self.isStaff(${user},${flags})` -+ }, -+ { -+ match: /hasFreePremium\(\){return this.isStaff\(\)\s*?\|\|/, -+ replace: "hasFreePremium(){return ", -+ } -+ ] -+ }, -+ { -+ find: ".Messages.DEV_NOTICE_STAGING", -+ predicate: () => settings.store.forceStagingBanner, -+ replacement: { -+ match: /window\.GLOBAL_ENV\.RELEASE_CHANNEL/, -+ replace: "\"staging\"" -+ } - } - ], - - start: () => enableStyle(hideBugReport), - stop: () => disableStyle(hideBugReport), - -+ 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"; --- -2.45.2 - |