Attempt deviceId workaround

This commit is contained in:
Jared Schoeny 2025-12-12 01:38:16 -10:00
parent e71f138933
commit fe4ecf5e09
2 changed files with 7 additions and 2 deletions

View File

@ -71,7 +71,11 @@ export async function getSignedPatchUrl(slug: string): Promise<{ ok: true; url:
}
}
export async function updatePatchDownloadCount(patchId: number, deviceId: string): Promise<{ ok: true; didIncrease: boolean } | { ok: false; error: string }> {
export async function updatePatchDownloadCount(patchId: number, deviceIdObscured: string[]): Promise<{ ok: true; didIncrease: boolean } | { ok: false; error: string }> {
if (deviceIdObscured.length !== 5) {
return { ok: false, error: "Invalid device ID" };
}
const deviceId = deviceIdObscured.join("-");
const supabase = await createClient();
const { error: updateError } = await supabase
.from("patch_downloads")

View File

@ -221,7 +221,8 @@ const HackActions: React.FC<HackActionsProps> = ({
deviceId = crypto.randomUUID();
localStorage.setItem(key, deviceId);
}
const result = await updatePatchDownloadCount(patchId, deviceId);
const deviceIdObscured = deviceId.split("-");
const result = await updatePatchDownloadCount(patchId, deviceIdObscured);
if (!result.ok) {
console.error(result.error);
} else if (result.didIncrease) {