From 9cc42bf4574cf98867d8974c0e3199c71828d6a8 Mon Sep 17 00:00:00 2001 From: Scab <104103312+ZoamIl@users.noreply.github.com> Date: Thu, 1 Aug 2024 10:10:30 +0300 Subject: [PATCH] MutualGroupDms: make display consistent with Mutual Servers (#2727) Co-authored-by: Cookie <52550063+Covkie@users.noreply.github.com> --- src/plugins/mutualGroupDMs/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/mutualGroupDMs/index.tsx b/src/plugins/mutualGroupDMs/index.tsx index 0fbf41e93..278501438 100644 --- a/src/plugins/mutualGroupDMs/index.tsx +++ b/src/plugins/mutualGroupDMs/index.tsx @@ -49,7 +49,7 @@ export default definePlugin({ find: ".Messages.MUTUAL_GUILDS_WITH_END_COUNT", // Note: the module is lazy-loaded replacement: { match: /(?<=\.tabBarItem.{0,50}MUTUAL_GUILDS.+?}\),)(?=.+?(\(0,\i\.jsxs?\)\(.{0,100}id:))/, - replace: '$self.isBotOrSelf(arguments[0].user)?null:$1"MUTUAL_GDMS",children:"Mutual Groups"}),' + replace: '$self.isBotOrSelf(arguments[0].user)?null:$1"MUTUAL_GDMS",children:$self.getMutualGDMCountText(arguments[0].user)}),' } }, { @@ -64,7 +64,7 @@ export default definePlugin({ replacement: [ { match: /(?<=onItemSelect:\i,children:)(\i)\.map/, - replace: "[...$1, ...($self.isBotOrSelf(arguments[0].user) ? [] : [{section:'MUTUAL_GDMS',text:'Mutual Groups'}])].map" + replace: "[...$1, ...($self.isBotOrSelf(arguments[0].user) ? [] : [{section:'MUTUAL_GDMS',text:$self.getMutualGDMCountText(arguments[0].user)}])].map" }, { match: /\(0,\i\.jsx\)\(\i,\{items:\i,section:(\i)/, @@ -76,6 +76,11 @@ export default definePlugin({ isBotOrSelf: (user: User) => user.bot || user.id === UserStore.getCurrentUser().id, + getMutualGDMCountText: (user: User) => { + const count = ChannelStore.getSortedPrivateChannels().filter(c => c.isGroupDM() && c.recipients.includes(user.id)).length; + return `${count === 0 ? "No" : count} Mutual Group${count !== 1 ? "s" : ""}`; + }, + renderMutualGDMs: ErrorBoundary.wrap(({ user, onClose }: { user: User, onClose: () => void; }) => { const entries = ChannelStore.getSortedPrivateChannels().filter(c => c.isGroupDM() && c.recipients.includes(user.id)).map(c => (