Commit 0c26337e by asranov0003

fix: generate device id

parent 6eeaed06
......@@ -4,7 +4,16 @@ export const generateDeviceId = (): string => {
let id = localStorage.getItem(`device_id-${TG_USER_ID}`);
if (!id) {
id = crypto.randomUUID();
if (crypto.randomUUID) {
id = crypto.randomUUID();
} else {
id = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0;
const v = c === "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}
localStorage.setItem(`device_id-${TG_USER_ID}`, id);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment