From 6f77e5b04594537277f57f8a3f4a387f921b3e33 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Fri, 10 Jul 2026 20:26:33 -0400 Subject: [PATCH] Timezones: Redo the pr --- .../timezones/TimezoneModal.tsx | 3 --- src/equicordplugins/timezones/index.tsx | 27 ++++++++++--------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/equicordplugins/timezones/TimezoneModal.tsx b/src/equicordplugins/timezones/TimezoneModal.tsx index 7aa21096e..83b289ce6 100644 --- a/src/equicordplugins/timezones/TimezoneModal.tsx +++ b/src/equicordplugins/timezones/TimezoneModal.tsx @@ -6,7 +6,6 @@ import * as DataStore from "@api/DataStore"; import { HeadingSecondary } from "@components/Heading"; -import { classNameFactory } from "@utils/css"; import { Margins } from "@utils/margins"; import { RenderModalProps } from "@vencord/discord-types"; import { Modal, SearchableSelect, useEffect, useMemo, useState } from "@webpack/common"; @@ -19,8 +18,6 @@ export async function setUserTimezone(userId: string, timezone: string | null) { await DataStore.set(DATASTORE_KEY, timezones); } -const cl = classNameFactory("vc-timezone-"); - export function SetTimezoneModal({ userId, modalProps, database }: { userId: string, modalProps: RenderModalProps; database?: boolean; }) { const [currentValue, setCurrentValue] = useState(null); diff --git a/src/equicordplugins/timezones/index.tsx b/src/equicordplugins/timezones/index.tsx index f0ced70a6..e2704b5f1 100644 --- a/src/equicordplugins/timezones/index.tsx +++ b/src/equicordplugins/timezones/index.tsx @@ -8,7 +8,7 @@ import "./styles.css"; import { NavContextMenuPatchCallback } from "@api/ContextMenu"; import * as DataStore from "@api/DataStore"; -import { definePluginSettings } from "@api/Settings"; +import { definePluginSettings, migratePluginSetting } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs, EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; @@ -42,14 +42,15 @@ const classes = findCssClassesLazy("timestamp", "compact", "contentOnly"); const locale = findByPropsLazy("getLocale"); export const settings = definePluginSettings({ - "Show Own Timezone": { + showOwnTimezone: { type: OptionType.BOOLEAN, description: "Show your own timezone in profiles and message headers", default: true }, - "24h Time": { + twentyFourHourFormat: { type: OptionType.BOOLEAN, + displayName: "24h Time", description: "Show time in 24h format", default: false }, @@ -146,7 +147,7 @@ export const settings = definePluginSettings({ function getTime(timezone: string, timestamp: string | number, props: Intl.DateTimeFormatOptions = {}) { const date = new Date(timestamp); const formatter = new Intl.DateTimeFormat(locale.getLocale() ?? "en-US", { - hour12: !settings.store["24h Time"], + hour12: !settings.store.twentyFourHourFormat, timeZone: timezone, ...props }); @@ -207,8 +208,8 @@ const TimestampComponent = ErrorBoundary.wrap(({ userId, timestamp, type }: Prop if (settings.store.showTimezoneInfo) { const userTimezone = getSystemTimezone(); - isLocal = timezone === userTimezone; - if (isLocal && !settings.store.showLocalTimezone) { + isLocal = timezone === userTimezone && !settings.store.showLocalTimezone; + if (isLocal) { displayTime = "local"; } else { const timezoneInfo = getTimezoneAbbreviation(timezone, currentTime); @@ -265,6 +266,8 @@ const userContextMenuPatch: NavContextMenuPatchCallback = (children, { user }: { children.push(, setTimezoneItem); }; +migratePluginSetting("Timezones", "showOwnTimezone", "Show Own Timezone"); +migratePluginSetting("Timezones", "twentyFourHourFormat", "24h Time"); export default definePlugin({ name: "Timezones", authors: [Devs.Aria, EquicordDevs.creations], @@ -349,24 +352,22 @@ export default definePlugin({ renderProfileTimezone: (props?: { user?: User; }) => { if (!settings.store.showProfileTime || !props?.user?.id) return null; - if (props.user.id === UserStore.getCurrentUser().id && !settings.store["Show Own Timezone"]) return null; + if (props.user.id === UserStore.getCurrentUser().id && !settings.store.showOwnTimezone) return null; return ; }, renderMessageTimezone: (props?: { message?: Message; }) => { - const { showMessageHeaderTime, recipientTimezoneInDms, "Show Own Timezone": showOwnTimezone } = settings.store; - + const { showMessageHeaderTime, recipientTimezoneInDms, showOwnTimezone } = settings.store; if (!showMessageHeaderTime || !props?.message) return null; let userId = props.message.author.id; if (userId === UserStore.getCurrentUser().id) { - const channel = recipientTimezoneInDms ? ChannelStore.getChannel(props.message.channel_id) : undefined; - const recipientId = channel?.type === 1 ? channel.recipients[0] : undefined; + if (!showOwnTimezone) return null; - if (recipientId && resolveUserTimezone(recipientId)) userId = recipientId; - else if (!showOwnTimezone) return null; + const channel = ChannelStore.getChannel(props.message.channel_id); + if (recipientTimezoneInDms) userId = channel?.getRecipientId() ?? userId; } return ;