Remove Extra Patch From MGDMs

This commit is contained in:
thororen1234 2024-06-06 03:39:36 -04:00
parent 6dd85a104b
commit be0225bcad

View file

@ -19,10 +19,9 @@
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import { isNonNullish } from "@utils/guards";
import { pluralise } from "@utils/misc";
import definePlugin from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { Avatar, ChannelStore, Clickable, IconUtils, RelationshipStore, ScrollerThin, UserStore, useStateFromStores } from "@webpack/common";
import { Avatar, ChannelStore, Clickable, IconUtils, RelationshipStore, ScrollerThin, UserStore } from "@webpack/common";
import { Channel, User } from "discord-types/general";
const SelectedChannelActionCreators = findByPropsLazy("selectPrivateChannel");
@ -64,13 +63,9 @@ export default definePlugin({
find: "Messages.USER_PROFILE_MUTUAL_GUILDS_PLACEHOLDER).with",
group: true,
replacement: [
{
match: /(?<=let\{user:(\i),.{0,700})(?=return\(null!=)/,
replace: "let vencordMutualGroupsCount=$self.useGDMCount($1.id);"
},
{
match: /(?<=(\i\.push)\(\{section:\i\.UserProfileSections\.MUTUAL_GUILDS,text:.{0,250}\}\)\)\}\))/,
replace: ',$1({section:"MUTUAL_GDMS",text:vencordMutualGroupsCount})'
replace: ',$1({section:"MUTUAL_GDMS",text:"Mutual Groups"})'
},
{
match: /(?<=(\i)===\i\.UserProfileSections\.MUTUAL_GUILDS?.{0,150}\}\):)/,
@ -80,11 +75,6 @@ export default definePlugin({
},
],
useGDMCount(userId: string) {
const state = useStateFromStores([ChannelStore], () => ChannelStore.getSortedPrivateChannels().filter(c => c.isGroupDM() && c.recipients.includes(userId))).length;
const label = "Mutual Group";
return state > 0 ? pluralise(state, label) : `No ${label}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 => (
<Clickable