Merge branch 'dev' into immediate-finds

This commit is contained in:
Nuckyz 2024-05-18 00:39:00 -03:00
commit dbee2d9ecc
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -7,6 +7,7 @@
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { getCurrentChannel } from "@utils/discord"; import { getCurrentChannel } from "@utils/discord";
import { Logger } from "@utils/Logger";
import { classes } from "@utils/misc"; import { classes } from "@utils/misc";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { findByProps } from "@webpack"; import { findByProps } from "@webpack";
@ -43,12 +44,21 @@ export default definePlugin({
{ {
find: ".userInfoSectionHeader,", find: ".userInfoSectionHeader,",
replacement: { replacement: {
match: /(\.Messages\.USER_PROFILE_MEMBER_SINCE.+?userId:(.+?)),textClassName:(\i\.userInfoText)}\)/, match: /(\.Messages\.USER_PROFILE_MEMBER_SINCE.+?userId:(.+?),textClassName:)(\i\.userInfoText)}\)/,
replace: (_, rest, userId, textClassName) => `${rest}}),$self.friendsSince({ userId: ${userId}, textClassName: ${textClassName} })` replace: (_, rest, userId, textClassName) => `${rest}!$self.getFriendSince(${userId}) ? ${textClassName} : void 0 }), $self.friendsSince({ userId: ${userId}, textClassName: ${textClassName} })`
} }
} }
], ],
getFriendSince(userId: string) {
try {
return RelationshipStore.getSince(userId);
} catch (err) {
new Logger("FriendsSince").error(err);
return null;
}
},
friendsSince: ErrorBoundary.wrap(({ userId, textClassName }: { userId: string; textClassName?: string; }) => { friendsSince: ErrorBoundary.wrap(({ userId, textClassName }: { userId: string; textClassName?: string; }) => {
const friendsSince = RelationshipStore.getSince(userId); const friendsSince = RelationshipStore.getSince(userId);
if (!friendsSince) return null; if (!friendsSince) return null;
@ -80,4 +90,3 @@ export default definePlugin({
); );
}, { noop: true }) }, { noop: true })
}); });