mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-07 05:42:55 -04:00
Timezones: Fix Refresh
This commit is contained in:
parent
b96f18d076
commit
734cbd579c
2 changed files with 3 additions and 5 deletions
|
@ -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 () => {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue