feat(front): use uuid for random ids

This commit is contained in:
Florent Chehab
2020-05-12 20:01:57 +02:00
parent 0be0baf655
commit 25bcdee083
3 changed files with 27 additions and 8 deletions

View File

@@ -10,16 +10,15 @@ import ReadOnlyService from "./services/ReadOnlyService";
import InfoService from "./services/InfoService";
import { getQueryVariable, getSubDir } from "./utils";
import ConfigService from "./services/ConfigService";
import { v4 as uuidv4 } from "uuid";
let whiteboardId = getQueryVariable("whiteboardid");
const randomid = getQueryVariable("randomid");
if (randomid && !whiteboardId) {
//set random whiteboard on empty whiteboardid
whiteboardId = Array(2)
.fill(null)
.map(() => Math.random().toString(36).substr(2))
.join("");
whiteboardId = uuidv4();
const urlParams = new URLSearchParams(window.location.search);
urlParams.delete("randomid");
urlParams.set("whiteboardid", whiteboardId);
window.location.search = urlParams;
}