From b36ae791cb3ca30c222d97ac017626fefee152a0 Mon Sep 17 00:00:00 2001 From: William Petit Date: Tue, 13 Oct 2020 11:04:32 +0200 Subject: [PATCH] =?UTF-8?q?Persistence=20de=20l'UUID=20de=20conf=C3=A9renc?= =?UTF-8?q?e=20dans=20le=20localStorage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/hooks/useConference.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/hooks/useConference.tsx b/client/src/hooks/useConference.tsx index 6295524..9582fc7 100644 --- a/client/src/hooks/useConference.tsx +++ b/client/src/hooks/useConference.tsx @@ -3,7 +3,13 @@ import { WebrtcProvider, } from 'y-webrtc' import { useEffect, useRef, useState } from 'react' import { uuidV4 } from '../util/uuid'; -const uuid = uuidV4(); +const UUIDKey = 'conference-uuid'; +let uuid = localStorage.getItem(UUIDKey); + +if (!uuid) { + uuid = uuidV4(); + localStorage.setItem(UUIDKey, uuid); +} export function useConference() { const docRef = useRef(new Y.Doc());