Timezones: Fix Refresh

This commit is contained in:
thororen1234 2025-05-28 14:21:23 -04:00
parent b96f18d076
commit 734cbd579c
No known key found for this signature in database
2 changed files with 3 additions and 5 deletions

View file

@ -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<string | null> {
export async function getTimezone(userId: string, force?: boolean): Promise<string | null> {
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 () => {

View file

@ -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);