mirror of
https://github.com/Hackdex-App/hackdex-website.git
synced 2026-04-22 06:57:19 -05:00
Workaround Safari bug for patch count update
This commit is contained in:
parent
fe4ecf5e09
commit
0c9c79f969
|
|
@ -221,13 +221,16 @@ const HackActions: React.FC<HackActionsProps> = ({
|
|||
deviceId = crypto.randomUUID();
|
||||
localStorage.setItem(key, deviceId);
|
||||
}
|
||||
const deviceIdObscured = deviceId.split("-");
|
||||
const result = await updatePatchDownloadCount(patchId, deviceIdObscured);
|
||||
if (!result.ok) {
|
||||
console.error(result.error);
|
||||
} else if (result.didIncrease) {
|
||||
window.dispatchEvent(new CustomEvent<DownloadEventDetail>("hack:patch-applied", { detail: { slug: hackSlug } }));
|
||||
}
|
||||
// Defer update to next tick to avoid Safari cancelling the request
|
||||
setTimeout(async () => {
|
||||
const deviceIdObscured = deviceId.split("-");
|
||||
const result = await updatePatchDownloadCount(patchId, deviceIdObscured);
|
||||
if (!result.ok) {
|
||||
console.error(result.error);
|
||||
} else if (result.didIncrease) {
|
||||
window.dispatchEvent(new CustomEvent<DownloadEventDetail>("hack:patch-applied", { detail: { slug: hackSlug } }));
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
} catch {}
|
||||
} catch (e: any) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user