PlainFolderIcon: Fix plugin not working (#3409)

This commit is contained in:
sadan4 2025-05-02 21:30:10 -04:00 committed by GitHub
parent bebf3dd068
commit 59974a162e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 45 additions and 32 deletions

View file

@ -61,7 +61,7 @@ function filterTreeWithTargetNode(children: any, predicate: (node: any) => boole
return true; return true;
} }
return filterTreeWithTargetNode(children.props.children, predicate); return filterTreeWithTargetNode(children.props?.children, predicate);
} }
@ -150,7 +150,7 @@ export default definePlugin({
}, },
// Export the isBetterFolders and betterFoldersExpandedIds variable to the Guild List component // Export the isBetterFolders and betterFoldersExpandedIds variable to the Guild List component
{ {
match: /0,\i\.jsxs?[^0}]{0,100}guildDiscoveryButton:\i,/g, match: /,{guildDiscoveryButton:\i,/g,
replace: "$&isBetterFolders:arguments[0]?.isBetterFolders,betterFoldersExpandedIds:arguments[0]?.betterFoldersExpandedIds," replace: "$&isBetterFolders:arguments[0]?.isBetterFolders,betterFoldersExpandedIds:arguments[0]?.betterFoldersExpandedIds,"
}, },
// Export the isBetterFolders variable to the folders component // Export the isBetterFolders variable to the folders component
@ -349,7 +349,12 @@ export default definePlugin({
return true; return true;
} }
return filterTreeWithTargetNode(child, child => child?.props?.renderTreeNode != null); try {
return filterTreeWithTargetNode(child, child => child?.props?.renderTreeNode != null);
} catch (e) {
console.error(e);
return true;
}
}; };
}, },

View file

@ -59,22 +59,21 @@ function renderClickableGDMs(mutualDms: Channel[], onClose: () => void) {
return mutualDms.map(c => ( return mutualDms.map(c => (
<Clickable <Clickable
key={c.id} key={c.id}
className={MutualsListClasses.row}
onClick={() => { onClick={() => {
onClose(); onClose();
SelectedChannelActionCreators.selectPrivateChannel(c.id); SelectedChannelActionCreators.selectPrivateChannel(c.id);
}} }}
> >
<div className={MutualsListClasses.row}> <Avatar
<Avatar src={IconUtils.getChannelIconURL({ id: c.id, icon: c.icon, size: 32 })}
src={IconUtils.getChannelIconURL({ id: c.id, icon: c.icon, size: 32 })} size="SIZE_40"
size="SIZE_40" className={MutualsListClasses.icon}
className={MutualsListClasses.icon} >
> </Avatar>
</Avatar> <div className={MutualsListClasses.details}>
<div className={MutualsListClasses.details}> <div className={MutualsListClasses.name}>{getGroupDMName(c)}</div>
<div className={MutualsListClasses.name}>{getGroupDMName(c)}</div> <div className={MutualsListClasses.nick}>{c.recipients.length + 1} Members</div>
<div className={MutualsListClasses.nick}>{c.recipients.length + 1} Members</div>
</div>
</div> </div>
</Clickable> </Clickable>
)); ));

View file

@ -16,28 +16,27 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import "./style.css";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
export default definePlugin({ export default definePlugin({
name: "PlainFolderIcon", name: "PlainFolderIcon",
description: "Doesn't show the small guild icons in folders", description: "Dont show the small guild icons in folders",
authors: [Devs.botato], authors: [Devs.botato],
patches: [{
find: ".expandedFolderIconWrapper", patches: [
replacement: [ {
// there are two elements, the first one is the plain folder icon find: ".folderPreviewGuildIconError",
// the second is the four guild preview icons replacement: [
// always show this one (the plain icons) {
{ // Discord always renders both plain and guild icons folders and uses a css transtion to switch between them
match: /\(\i\|\|\i\)&&(\(.{0,40}\(\i\.animated)/, match: /(?<=.folderButtonContent]:(!\i))/,
replace: "$1", replace: (_, hasFolderButtonContentClass) => `,"vc-plainFolderIcon-plain":${hasFolderButtonContentClass}`
}, }
// and never show this one (the guild preview icons)
{ ]
match: /\(\i\|\|!\i\)&&(\(.{0,40}\(\i\.animated)/, }
replace: "false&&$1", ]
}
]
}]
}); });

View file

@ -0,0 +1,10 @@
.vc-plainFolderIcon-plain {
/* Without this, they are a bit laggier */
transition: none !important;
/* Don't show the mini guild icons */
transform: translateZ(0);
/* The new icons are fully transparent. Add a sane default to match the old behavior */
background-color: color-mix(in oklab, var(--custom-folder-color, var(--bg-brand)) 30%, var(--background-surface-higher) 70%);
}