From 0b4538f1cf973dfb218c866c9a49b3a6d8ff3211 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sat, 6 Sep 2025 10:51:48 -0400 Subject: [PATCH] CustomTimestamps: Optimize Finds --- .../customTimestamps/index.tsx | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/equicordplugins/customTimestamps/index.tsx b/src/equicordplugins/customTimestamps/index.tsx index cf72553dd..f9eab235d 100644 --- a/src/equicordplugins/customTimestamps/index.tsx +++ b/src/equicordplugins/customTimestamps/index.tsx @@ -114,7 +114,7 @@ const TimeRow = (props: TimeRowProps) => { <> {props.format.name} {props.format.description} - + ); }; @@ -125,17 +125,14 @@ const MessagePreview = findComponentByCodeLazy<{ compact: boolean, isGroupStart: boolean, className: string, - hideSimpleEmbedContent: boolean + hideSimpleEmbedContent: boolean; }>(/previewGuildId:\i,preview:\i,/); -const createMessage = findByCodeLazy(/channelId:\i,content:\i,tts:\i=!1,/); -const populateMessagePrototype = findByCodeLazy(/PREMIUM_REFERRAL&&\(\i=\i.default.isProbablyAValidSnowflake\(/); +const createBotMessage = findByCodeLazy('username:"Clyde"'); +const populateMessagePrototype = findByCodeLazy("isProbablyAValidSnowflake", "messageReference:"); -const DemoMessage = (props: { msgId, compact, message, date: Date | undefined, isGroupStart?: boolean }) => { - const message = createMessage({ - content: props.message || "This is a demo message to preview the custom timestamps.", - channelId: "1337", - state: "SENT" - }); +const DemoMessage = (props: { msgId, compact, message, date: Date | undefined, isGroupStart?: boolean; }) => { + const message = createBotMessage({ content: props.message, channelId: "1337", embeds: [] }); + message.author = UserStore.getCurrentUser(); message.id = props.msgId; message.timestamp = moment(props.date ?? new Date()); const user = UserStore.getCurrentUser(); @@ -169,14 +166,14 @@ const DemoMessageContainer = ErrorBoundary.wrap(() => { return (
setIsCompact(!isCompact)}> + message={`Click me to switch to ${isCompact ? "cozy" : "compact"} mode`} isGroupStart={true} + date={aMonthAgo.current} /> + isGroupStart={true} date={lastWeek.current} /> + isGroupStart={true} date={yesterday.current} /> + date={today.current} />
); }, { noop: true }); @@ -196,12 +193,12 @@ const settings = definePluginSettings({ return ( <> - + {Object.entries(timeFormats).map(([key, value]) => ( {key === "sameDayFormat" && (
- + Calendar formats How to format the [calendar] value if used in the above timestamps. @@ -229,7 +226,7 @@ const settings = definePluginSettings({ lastDayFormat: string; lastWeekFormat: string; sameElseFormat: string; - } + }; }>(); export default definePlugin({