From 734cbd579c83129ae545c18f0263c04f8f845de9 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Wed, 28 May 2025 14:21:23 -0400 Subject: [PATCH] Timezones: Fix Refresh --- src/equicordplugins/timezones/database.tsx | 4 ++-- src/equicordplugins/timezones/index.tsx | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/equicordplugins/timezones/database.tsx b/src/equicordplugins/timezones/database.tsx index 45e13b58c..643f760bd 100644 --- a/src/equicordplugins/timezones/database.tsx +++ b/src/equicordplugins/timezones/database.tsx @@ -26,11 +26,11 @@ export async function setUserDatabaseTimezone(userId: string, timezone: string | await DataStore.set(DATASTORE_KEY, databaseTimezones); } -export async function getTimezone(userId: string): Promise { +export async function getTimezone(userId: string, force?: boolean): Promise { const now = Date.now(); const cached = databaseTimezones[userId]; - if (cached && now < cached.expires) return cached.value; + if (cached && now < cached.expires && !force) return cached.value; if (!pendingRequests[userId]) { pendingRequests[userId] = (async () => { diff --git a/src/equicordplugins/timezones/index.tsx b/src/equicordplugins/timezones/index.tsx index 6597ea4a6..7fca1b34e 100644 --- a/src/equicordplugins/timezones/index.tsx +++ b/src/equicordplugins/timezones/index.tsx @@ -201,9 +201,7 @@ const userContextMenuPatch: NavContextMenuPatchCallback = (children, { user }: { showToast("Refreshing timezone...", Toasts.Type.CLOCK); try { - const timezone = await getTimezone(user.id); - setUserDatabaseTimezone(user.id, timezone); - timezones[user.id] = timezone; + timezones[user.id] = await getTimezone(user.id, true); showToast("Timezone refreshed successfully!", Toasts.Type.SUCCESS); } catch (error) { console.error("Failed to refresh timezone:", error);