From a765212cfea712f67dd82d025f8f9a56558cdbbe Mon Sep 17 00:00:00 2001 From: thororen <78185467+thororen1234@users.noreply.github.com> Date: Wed, 11 Sep 2024 06:50:55 -0400 Subject: [PATCH 1/3] NoTrack: Fix blocking analytics (#2857) --- src/plugins/_core/noTrack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/_core/noTrack.ts b/src/plugins/_core/noTrack.ts index de1c20562..8d6a1e76d 100644 --- a/src/plugins/_core/noTrack.ts +++ b/src/plugins/_core/noTrack.ts @@ -48,7 +48,7 @@ export default definePlugin({ }, }, { - find: ".METRICS,", + find: ".METRICS", replacement: [ { match: /this\._intervalId=/, From f27361f017330e8957b12b6eabcf4930ffcf7eb4 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 11 Sep 2024 08:13:23 -0300 Subject: [PATCH 2/3] TimeBarAllActivities: Fix timestamp component --- src/plugins/ignoreActivities/index.tsx | 9 +------ src/plugins/noPendingCount/index.ts | 11 +-------- src/plugins/timeBarAllActivities/index.tsx | 28 ++++++++++++++-------- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index 02261b5ba..8c36e1d75 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -266,7 +266,7 @@ export default definePlugin({ replace: (m, props, nowPlaying) => `${m}$self.renderToggleGameActivityButton(${props},${nowPlaying}),` } }, - // Discord has 3 different components for activities. Currently, the last is the one being used + // Discord has 2 different components for activities. Currently, the last is the one being used { find: ".activityTitleText,variant", replacement: { @@ -274,13 +274,6 @@ export default definePlugin({ replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),` }, }, - { - find: ".activityCardDetails,children", - replacement: { - match: /\.activityCardDetails.+?children:(\i\.application)\.name.*?}\),/, - replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),` - } - }, { find: ".promotedLabelWrapperNonBanner,children", replacement: { diff --git a/src/plugins/noPendingCount/index.ts b/src/plugins/noPendingCount/index.ts index 0995621fa..d3e27563b 100644 --- a/src/plugins/noPendingCount/index.ts +++ b/src/plugins/noPendingCount/index.ts @@ -62,16 +62,7 @@ export default definePlugin({ replace: "return 0;" } }, - // New message requests hook - { - find: 'location:"use-message-requests-count"', - predicate: () => settings.store.hideMessageRequestsCount, - replacement: { - match: /getNonChannelAckId\(\i\.\i\.MESSAGE_REQUESTS\).+?return /, - replace: "$&0;" - } - }, - // Old message requests hook + // Message requests hook { find: "getMessageRequestsCount(){", predicate: () => settings.store.hideMessageRequestsCount, diff --git a/src/plugins/timeBarAllActivities/index.tsx b/src/plugins/timeBarAllActivities/index.tsx index 91b1bc2f1..660d20bbf 100644 --- a/src/plugins/timeBarAllActivities/index.tsx +++ b/src/plugins/timeBarAllActivities/index.tsx @@ -5,9 +5,11 @@ */ import { definePluginSettings } from "@api/Settings"; +import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findComponentByCodeLazy } from "@webpack"; +import { RequiredDeep } from "type-fest"; interface Activity { timestamps?: ActivityTimestamps; @@ -18,7 +20,15 @@ interface ActivityTimestamps { end?: string; } -const ActivityTimeBar = findComponentByCodeLazy(".Millis.HALF_SECOND", ".bar", ".progress"); +interface TimebarComponentProps { + activity: Activity; +} + +const ActivityTimeBar = findComponentByCodeLazy(".bar", ".progress", "(100*"); + +function isActivityTimestamped(activity: Activity): activity is RequiredDeep { + return activity.timestamps != null && activity.timestamps.start != null && activity.timestamps.end != null; +} export const settings = definePluginSettings({ hideActivityDetailText: { @@ -45,7 +55,7 @@ export default definePlugin({ // Insert Spotify time bar component { match: /\(0,.{0,30}activity:(\i),className:\i\.badges\}\)/g, - replace: "$&,$self.getTimeBar($1)" + replace: "$&,$self.TimebarComponent({activity:$1})" }, // Hide the large title on listening activities, to make them look more like Spotify (also visible from hovering over the large icon) { @@ -64,13 +74,11 @@ export default definePlugin({ } ], - isActivityTimestamped(activity: Activity) { - return activity.timestamps != null && activity.timestamps.start != null && activity.timestamps.end != null; - }, + isActivityTimestamped, - getTimeBar(activity: Activity) { - if (this.isActivityTimestamped(activity)) { - return ; - } - } + TimebarComponent: ErrorBoundary.wrap(({ activity }: TimebarComponentProps) => { + if (!isActivityTimestamped(activity)) return null; + + return ; + }, { noop: true }) }); From b82254235204a3f0e784c623d499b2e3274a83d5 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Thu, 12 Sep 2024 01:23:43 -0400 Subject: [PATCH 3/3] BetterFolders: Fix pending clan applications (#2867) --- src/plugins/betterFolders/README.md | 11 ++++++++ src/plugins/betterFolders/index.tsx | 39 +++++++++++++++++++---------- 2 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 src/plugins/betterFolders/README.md diff --git a/src/plugins/betterFolders/README.md b/src/plugins/betterFolders/README.md new file mode 100644 index 000000000..658c6f1db --- /dev/null +++ b/src/plugins/betterFolders/README.md @@ -0,0 +1,11 @@ +# Better Folders + +Better Folders offers a variety of options to improve your folder experience + +Always show the folder icon, regardless of if the folder is open or not + +Only have one folder open at a time + +Open folders in a sidebar: + +![A folder open in a separate sidebar](https://github.com/user-attachments/assets/432d3146-8091-4bae-9c1e-c19046c72947) diff --git a/src/plugins/betterFolders/index.tsx b/src/plugins/betterFolders/index.tsx index 0bef0933d..c2969988b 100644 --- a/src/plugins/betterFolders/index.tsx +++ b/src/plugins/betterFolders/index.tsx @@ -30,9 +30,9 @@ enum FolderIconDisplay { MoreThanOneFolderExpanded } -const GuildsTree = findLazy(m => m.prototype?.moveNextTo); -const SortedGuildStore = findStoreLazy("SortedGuildStore"); export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore"); +const SortedGuildStore = findStoreLazy("SortedGuildStore"); +const GuildsTree = findLazy(m => m.prototype?.moveNextTo); const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand"); let lastGuildId = null as string | null; @@ -118,17 +118,17 @@ export default definePlugin({ // If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders { match: /\[(\i)\]=(\(0,\i\.\i\).{0,40}getGuildsTree\(\).+?}\))(?=,)/, - replace: (_, originalTreeVar, rest) => `[betterFoldersOriginalTree]=${rest},${originalTreeVar}=$self.getGuildTree(!!arguments[0].isBetterFolders,betterFoldersOriginalTree,arguments[0].betterFoldersExpandedIds)` + replace: (_, originalTreeVar, rest) => `[betterFoldersOriginalTree]=${rest},${originalTreeVar}=$self.getGuildTree(!!arguments[0]?.isBetterFolders,betterFoldersOriginalTree,arguments[0]?.betterFoldersExpandedIds)` }, // If we are rendering the Better Folders sidebar, we filter out everything but the servers and folders from the GuildsBar Guild List children { match: /lastTargetNode:\i\[\i\.length-1\].+?Fragment.+?\]}\)\]/, - replace: "$&.filter($self.makeGuildsBarGuildListFilter(!!arguments[0].isBetterFolders))" + replace: "$&.filter($self.makeGuildsBarGuildListFilter(!!arguments[0]?.isBetterFolders))" }, // If we are rendering the Better Folders sidebar, we filter out everything but the scroller for the guild list from the GuildsBar Tree children { match: /unreadMentionsIndicatorBottom,.+?}\)\]/, - replace: "$&.filter($self.makeGuildsBarTreeFilter(!!arguments[0].isBetterFolders))" + replace: "$&.filter($self.makeGuildsBarTreeFilter(!!arguments[0]?.isBetterFolders))" }, // Export the isBetterFolders variable to the folders component { @@ -167,31 +167,31 @@ export default definePlugin({ { predicate: () => settings.store.keepIcons, match: /(?<=let{folderNode:\i,setNodeRef:\i,.+?expanded:(\i),.+?;)(?=let)/, - replace: (_, isExpanded) => `${isExpanded}=!!arguments[0].isBetterFolders&&${isExpanded};` + replace: (_, isExpanded) => `${isExpanded}=!!arguments[0]?.isBetterFolders&&${isExpanded};` }, // Disable expanding and collapsing folders transition in the normal GuildsBar sidebar { predicate: () => !settings.store.keepIcons, match: /(?<=\.Messages\.SERVER_FOLDER_PLACEHOLDER.+?useTransition\)\()/, - replace: "!!arguments[0].isBetterFolders&&" + replace: "$self.shouldShowTransition(arguments[0])&&" }, // If we are rendering the normal GuildsBar sidebar, we avoid rendering guilds from folders that are expanded { predicate: () => !settings.store.keepIcons, match: /expandedFolderBackground,.+?,(?=\i\(\(\i,\i,\i\)=>{let{key.{0,45}ul)(?<=selected:\i,expanded:(\i),.+?)/, - replace: (m, isExpanded) => `${m}!arguments[0].isBetterFolders&&${isExpanded}?null:` + replace: (m, isExpanded) => `${m}$self.shouldRenderContents(arguments[0],${isExpanded})?null:` }, { // Decide if we should render the expanded folder background if we are rendering the Better Folders sidebar predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always, match: /(?<=\.wrapper,children:\[)/, - replace: "$self.shouldShowFolderIconAndBackground(!!arguments[0].isBetterFolders,arguments[0].betterFoldersExpandedIds)&&" + replace: "$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)&&" }, { // Decide if we should render the expanded folder icon if we are rendering the Better Folders sidebar predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always, match: /(?<=\.expandedFolderBackground.+?}\),)(?=\i,)/, - replace: "!$self.shouldShowFolderIconAndBackground(!!arguments[0].isBetterFolders,arguments[0].betterFoldersExpandedIds)?null:" + replace: "!$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)?null:" } ] }, @@ -201,7 +201,7 @@ export default definePlugin({ replacement: { // Render the Better Folders sidebar match: /(?<=({className:\i\.guilds,themeOverride:\i})\))/, - replace: ",$self.FolderSideBar($1)" + replace: ",$self.FolderSideBar({...$1})" } }, { @@ -306,7 +306,20 @@ export default definePlugin({ } }, - FolderSideBar: guildsBarProps => , + shouldShowTransition(props: any) { + // Pending guilds + if (props?.folderNode?.id === 1) return true; - closeFolders + return !!props?.isBetterFolders; + }, + + shouldRenderContents(props: any, isExpanded: boolean) { + // Pending guilds + if (props?.folderNode?.id === 1) return false; + + return !props?.isBetterFolders && isExpanded; + }, + + FolderSideBar, + closeFolders, });