Persistence de l'UUID de conférence dans le localStorage

This commit is contained in:
wpetit 2020-10-13 11:04:32 +02:00
parent 50ec72fcf4
commit b36ae791cb
1 changed files with 7 additions and 1 deletions

View File

@ -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());