mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-07 13:43:03 -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);
|
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 now = Date.now();
|
||||||
|
|
||||||
const cached = databaseTimezones[userId];
|
const cached = databaseTimezones[userId];
|
||||||
if (cached && now < cached.expires) return cached.value;
|
if (cached && now < cached.expires && !force) return cached.value;
|
||||||
|
|
||||||
if (!pendingRequests[userId]) {
|
if (!pendingRequests[userId]) {
|
||||||
pendingRequests[userId] = (async () => {
|
pendingRequests[userId] = (async () => {
|
||||||
|
|
|
@ -201,9 +201,7 @@ const userContextMenuPatch: NavContextMenuPatchCallback = (children, { user }: {
|
||||||
showToast("Refreshing timezone...", Toasts.Type.CLOCK);
|
showToast("Refreshing timezone...", Toasts.Type.CLOCK);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const timezone = await getTimezone(user.id);
|
timezones[user.id] = await getTimezone(user.id, true);
|
||||||
setUserDatabaseTimezone(user.id, timezone);
|
|
||||||
timezones[user.id] = timezone;
|
|
||||||
showToast("Timezone refreshed successfully!", Toasts.Type.SUCCESS);
|
showToast("Timezone refreshed successfully!", Toasts.Type.SUCCESS);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to refresh timezone:", error);
|
console.error("Failed to refresh timezone:", error);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue