fix showconnections in new profiles (#2567)

Co-authored-by: Vendicated <vendicated@riseup.net>
This commit is contained in:
Masterjoona 2024-06-08 19:33:58 +03:00 committed by Vendicated
parent 4ec01d0f40
commit 62830464af
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18

View file

@ -74,15 +74,15 @@ interface ConnectionPlatform {
icon: { lightSVG: string, darkSVG: string; }; icon: { lightSVG: string, darkSVG: string; };
} }
const profilePopoutComponent = ErrorBoundary.wrap((props: { user: User, displayProfile; }) => const profilePopoutComponent = ErrorBoundary.wrap((props: { user: User, displayProfile, compactSpacing; }) =>
<ConnectionsComponent id={props.user.id} theme={getProfileThemeProps(props).theme} /> <ConnectionsComponent id={props.user.id} theme={getProfileThemeProps(props).theme} compactSpacing={props.compactSpacing} />
); );
const profilePanelComponent = ErrorBoundary.wrap(({ id }: { id: string; }) => const profilePanelComponent = ErrorBoundary.wrap(({ id }: { id: string; }) =>
<ConnectionsComponent id={id} theme={ThemeStore.theme} /> <ConnectionsComponent id={id} theme={ThemeStore.theme} />
); );
function ConnectionsComponent({ id, theme }: { id: string, theme: string; }) { function ConnectionsComponent({ id, theme, compactSpacing }: { id: string, theme: string, compactSpacing?: boolean; }) {
const profile = UserProfileStore.getUserProfile(id); const profile = UserProfileStore.getUserProfile(id);
if (!profile) if (!profile)
return null; return null;
@ -91,8 +91,10 @@ function ConnectionsComponent({ id, theme }: { id: string, theme: string; }) {
if (!connections?.length) if (!connections?.length)
return null; return null;
const Container = compactSpacing ? "div" : Section;
return ( return (
<Section> <Container>
<Text <Text
tag="h2" tag="h2"
variant="eyebrow" variant="eyebrow"
@ -107,7 +109,7 @@ function ConnectionsComponent({ id, theme }: { id: string, theme: string; }) {
}}> }}>
{connections.map(connection => <CompactConnectionComponent connection={connection} theme={theme} />)} {connections.map(connection => <CompactConnectionComponent connection={connection} theme={theme} />)}
</Flex> </Flex>
</Section> </Container>
); );
} }
@ -178,7 +180,7 @@ export default definePlugin({
find: "{isUsingGuildBio:null!==(", find: "{isUsingGuildBio:null!==(",
replacement: { replacement: {
match: /,theme:\i\}\)(?=,.{0,150}setNote:)/, match: /,theme:\i\}\)(?=,.{0,150}setNote:)/,
replace: "$&,$self.profilePopoutComponent({ user: arguments[0].user, displayProfile: arguments[0].displayProfile })" replace: "$&,$self.profilePopoutComponent({ user: arguments[0].user, displayProfile: arguments[0].displayProfile, compactSpacing: false })"
} }
}, },
{ {
@ -188,6 +190,13 @@ export default definePlugin({
match: /\(0,\i\.jsx\)\(\i\.\i,\{\}\).{0,100}setNote:(?=.+?channelId:(\i).id)/, match: /\(0,\i\.jsx\)\(\i\.\i,\{\}\).{0,100}setNote:(?=.+?channelId:(\i).id)/,
replace: "$self.profilePanelComponent({ id: $1.recipients[0] }),$&" replace: "$self.profilePanelComponent({ id: $1.recipients[0] }),$&"
} }
},
{
find: "autoFocusNote:!0})",
replacement: {
match: /{autoFocusNote:!1}\)}\)(?<=user:(\i),bio:null==(\i)\?.+?)/,
replace: "$&,$self.profilePopoutComponent({ user: $1, displayProfile: $2, compactSpacing: true })"
}
} }
], ],
settings, settings,