From 6e2c8e5984ac38f6ccc62dc3908bd5064fb5c028 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Wed, 30 Apr 2025 22:56:18 -0400 Subject: [PATCH] Fixes For Patches Co-Authored-By: sadan4 <117494111+sadan4@users.noreply.github.com> --- src/plugins/betterFolders/index.tsx | 42 +++++++++++++++--------- src/plugins/plainFolderIcon/index.ts | 21 ++++++------ src/plugins/plainFolderIcon/styles.css | 12 +++++++ src/plugins/reviewDB/index.tsx | 3 +- src/plugins/showHiddenChannels/index.tsx | 2 +- 5 files changed, 52 insertions(+), 28 deletions(-) create mode 100644 src/plugins/plainFolderIcon/styles.css diff --git a/src/plugins/betterFolders/index.tsx b/src/plugins/betterFolders/index.tsx index 1bb52944..ef12ff8f 100644 --- a/src/plugins/betterFolders/index.tsx +++ b/src/plugins/betterFolders/index.tsx @@ -119,7 +119,7 @@ export default definePlugin({ predicate: () => settings.store.sidebar, replacement: [ // Create the isBetterFolders variable in the GuildsBar component - // Needed because we access this from a closure so we can't use arguments[0] + // Needed because we access this from a non-arrow closure so we can't use arguments[0] { match: /let{disableAppDownload:\i=\i\.isPlatformEmbedded,isOverlay:.+?(?=}=\i,)/, replace: "$&,isBetterFolders" @@ -156,6 +156,18 @@ export default definePlugin({ match: /(?=\(0,\i\.jsxs?\)[^0]+fullWidth:)/, replace: "!!arguments[0]?.isBetterFolders?null:" }, + // On the other sidebar version, dms are rendered separately. + // We need to filter them out + { + match: /fullWidth:!0.+?lurkingGuildIds.+?\]/, + replace: "$&.filter($self.makeGuildsBarTreeFilter(!!arguments[0]?.isBetterFolders))" + }, + // if you click the (NEW) button on the better folders sidebar + // it will end up in some infinite loop + { + match: /unreadMentionsFixedFooter\].+?\]/, + replace: "$&.filter($self.makeNewButtonFilter(!!arguments[0]?.isBetterFolders))" + }, // Export the isBetterFolders variable to the folders component { match: /switch\(\i\.type\){case \i\.\i\.FOLDER:.+?folderNode:\i,/, @@ -184,7 +196,7 @@ export default definePlugin({ ] }, { - find: ".expandedFolderBackground,", + find: ".FOLDER_ITEM_ANIMATION_DURATION),", predicate: () => settings.store.sidebar, replacement: [ // We use arguments[0] to access the isBetterFolders variable in this nested folder component (the parent exports all the props so we don't have to patch it) @@ -204,27 +216,20 @@ export default definePlugin({ // 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),.+?)/, + match: /folderGroupBackground.*?,(?=\i\(\(\i,\i,\i\)=>{let{key.+?"ul")(?<=selected:\i,expanded:(\i),.+?)/, 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 { - // Decide if we should render the expanded folder background if we are rendering the Better Folders sidebar predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always, - match: /\.isExpanded\),.{0,30}children:\[/, + match: /\.isExpanded].{0,110}children:\[/, 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 { - // 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,)/, + match: /(?<=\.folderGroupBackground.*?}\),)(?=\i,)/, replace: "!$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)?null:" - }, - { - // Discord adds a slight bottom margin of 4px when it's expanded - // Which looks off when there's nothing open in the folder - predicate: () => !settings.store.keepIcons, - match: /(?=className:.{0,50}folderIcon)/, - replace: "style:arguments[0]?.isBetterFolders?{}:{marginBottom:0}," } ] }, @@ -340,7 +345,6 @@ export default definePlugin({ makeGuildsBarTreeFilter(isBetterFolders: boolean) { return child => { if (!isBetterFolders) return true; - return !!child?.props?.renderTreeNode; }; }, @@ -360,6 +364,14 @@ export default definePlugin({ } }, + makeNewButtonFilter(isBetterFolders: boolean) { + return child => { + if (!isBetterFolders) return true; + + return !child?.props?.barClassName; + }; + }, + shouldShowTransition(props: any) { // Pending guilds if (props?.folderNode?.id === 1) return true; diff --git a/src/plugins/plainFolderIcon/index.ts b/src/plugins/plainFolderIcon/index.ts index bb6876b5..5870d7e6 100644 --- a/src/plugins/plainFolderIcon/index.ts +++ b/src/plugins/plainFolderIcon/index.ts @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +import "./styles.css"; + import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; @@ -23,21 +25,18 @@ export default definePlugin({ name: "PlainFolderIcon", description: "Doesn't show the small guild icons in folders", authors: [Devs.botato], + + folderClassName: "vc-plainFolderIcon-plain", + patches: [{ - find: ".expandedFolderIconWrapper", + find: ".folderPreviewGuildIconError", replacement: [ - // there are two elements, the first one is the plain folder icon - // the second is the four guild preview icons - // always show this one (the plain icons) { - match: /\(\i\|\|\i\)&&(\(.{0,40}\(\i\.animated)/, - replace: "$1", - }, - // and never show this one (the guild preview icons) - { - match: /\(\i\|\|!\i\)&&(\(.{0,40}\(\i\.animated)/, - replace: "false&&$1", + // Discord always renders both and uses a css transtion to switch bewteen them + match: /.folderButtonContent]:(!\i)/, + replace: (m, cond) => `${m},[$self.folderClassName]:${cond}` } + ] }] }); diff --git a/src/plugins/plainFolderIcon/styles.css b/src/plugins/plainFolderIcon/styles.css new file mode 100644 index 00000000..f832b404 --- /dev/null +++ b/src/plugins/plainFolderIcon/styles.css @@ -0,0 +1,12 @@ +.vc-plainFolderIcon-plain { + /* Without this, this are a bit laggier */ + transition: none !important; + + /* Don't show the mini guild icons */ + transform: none; +} + +.vc-plainFolderIcon-plain svg { + width: 35px; + height: 35px; +} diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index 7a61821b..f45da089 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -76,6 +76,7 @@ export default definePlugin({ }, patches: [ + // In the user popout. eg: when clicking the name in chat { find: ".POPOUT,user:", replacement: { @@ -90,8 +91,8 @@ export default definePlugin({ replace: "$1$self.BiteSizeReviewsButton({user:arguments[0].user}),$2" } }, + // places like the user profile on the right in dms { - // places like the user profile on the right in dms find: 'location:"UserProfileSiebar"', replacement: { match: /(children:\[)([^[]+shouldShowTooltip:)/, diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index 21598633..3c55295c 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -357,7 +357,7 @@ export default definePlugin({ ] }, { - find: "overflowCountVariant", + find: ".SIZE_24,overflowCountVariant:", replacement: [ { // Create a variable for the channel prop