From 61977e5b9b7015d8fd590e46d971c8b27df8127a Mon Sep 17 00:00:00 2001 From: Ally Founder Date: Tue, 18 Aug 2026 22:30:34 -0400 Subject: [PATCH] BetterTimestamps: add option to hide date on today's messages/divider --- plugins/better-timestamps/src/lib/renderTimestamp.ts | 9 +++++++++ plugins/better-timestamps/src/patches/rowManager.ts | 7 ++++++- plugins/better-timestamps/src/ui/Settings.tsx | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/plugins/better-timestamps/src/lib/renderTimestamp.ts b/plugins/better-timestamps/src/lib/renderTimestamp.ts index a3a42a9..104ee6b 100644 --- a/plugins/better-timestamps/src/lib/renderTimestamp.ts +++ b/plugins/better-timestamps/src/lib/renderTimestamp.ts @@ -1,9 +1,18 @@ +import { moment } from "@vendetta/metro/common"; import { storage } from "@vendetta/plugin"; export type TimestampMode = "calendar" | "relative" | "custom" | "iso"; export default function renderTimestamp(timestamp: any, mode: TimestampMode = storage.selected): string { try { + if ( + storage.hideDateIfToday && + (mode === "calendar" || mode === "custom") && + typeof timestamp.isSame === "function" && + timestamp.isSame(moment(), "day") + ) { + return timestamp.format("LT"); + } switch (mode) { case "calendar": return timestamp.calendar(); case "relative": return timestamp.fromNow(); diff --git a/plugins/better-timestamps/src/patches/rowManager.ts b/plugins/better-timestamps/src/patches/rowManager.ts index 8b4f3a4..f19498a 100644 --- a/plugins/better-timestamps/src/patches/rowManager.ts +++ b/plugins/better-timestamps/src/patches/rowManager.ts @@ -42,7 +42,12 @@ export default function patchRowManager(): () => void { const parsed = parseTimestamp(row.message.timestamp); row.message.__customTimestamp = wrapTimestamp(parsed); } else if (row.rowType === "day") { - row.text = renderTimestamp(moment(row.text, "LL")); + const parsed = moment(row.text, "LL"); + if (storage.hideDateIfToday && parsed.isValid() && parsed.isSame(moment(), "day")) { + row.text = "Today"; + } else { + row.text = renderTimestamp(parsed); + } } } catch { // Leave this row's timestamp untouched. diff --git a/plugins/better-timestamps/src/ui/Settings.tsx b/plugins/better-timestamps/src/ui/Settings.tsx index e784202..91aff59 100644 --- a/plugins/better-timestamps/src/ui/Settings.tsx +++ b/plugins/better-timestamps/src/ui/Settings.tsx @@ -47,6 +47,12 @@ export default function Settings() { })} + { storage.hideDateIfToday = v; }} + />