crappy event handling
This commit is contained in:
parent
f93cabb99d
commit
3dc0135b48
8 changed files with 112 additions and 9 deletions
|
@ -9,7 +9,7 @@ function useConferenceData(
|
|||
const [conferenceData, setConferenceDataLocal] = useState<ConferenceData>();
|
||||
|
||||
const setConferenceData = (newData: ConferenceData) => {
|
||||
console.log("[Rooms] set conferenceData");
|
||||
console.log("[Rooms] set conferenceData", conferenceData);
|
||||
sendMessage(JSON.stringify(newData));
|
||||
setConferenceDataLocal(newData);
|
||||
setUserInfo({ displayName: newData.displayName, email: "" });
|
||||
|
|
30
frontend/src/hooks/useJitsiEventCapture.tsx
Normal file
30
frontend/src/hooks/useJitsiEventCapture.tsx
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { DisplayNameChangeEvent } from "../background/jitsi/eventListeners";
|
||||
|
||||
function useJitsiEventCapture(displayNameChangeHandler: Function) {
|
||||
const [displayNameChangeEvent, setDisplayNameChangeEventLocal] =
|
||||
useState<DisplayNameChangeEvent>();
|
||||
// const [displayNameChangeHandler, setDisplayNameChangeHandler] =
|
||||
// useState<Function>();
|
||||
|
||||
const setDisplayNameChangeEvent = useCallback(
|
||||
(newValue: DisplayNameChangeEvent) => {
|
||||
console.log("[Rooms] newValue", newValue, displayNameChangeEvent);
|
||||
if (displayNameChangeEvent != newValue) {
|
||||
setDisplayNameChangeEventLocal(newValue);
|
||||
}
|
||||
},
|
||||
[setDisplayNameChangeEventLocal]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("[Rooms] displayNameChangeHandler", displayNameChangeEvent);
|
||||
displayNameChangeHandler &&
|
||||
displayNameChangeEvent &&
|
||||
displayNameChangeHandler(displayNameChangeEvent);
|
||||
}, [displayNameChangeEvent]);
|
||||
|
||||
return { setDisplayNameChangeEvent };
|
||||
}
|
||||
|
||||
export default useJitsiEventCapture;
|
|
@ -18,7 +18,7 @@ function useLocalUser() {
|
|||
|
||||
function getUserInfoFromCookie(): UserInfo {
|
||||
let cookie = getCookie(USER_COOKIE_NAME);
|
||||
console.log("[Rooms] getUserNameFromCookie 1", cookie);
|
||||
console.log("[Rooms] getUserNameFromCookie", cookie);
|
||||
if (cookie) return JSON.parse(cookie);
|
||||
return {
|
||||
displayName: "unknown traveller",
|
||||
|
@ -27,6 +27,7 @@ function getUserInfoFromCookie(): UserInfo {
|
|||
}
|
||||
|
||||
function storeUserInfoInCookie(userInfo: UserInfo) {
|
||||
console.log("[Rooms] storeUserInfoInCookie", userInfo);
|
||||
setCookie(USER_COOKIE_NAME, JSON.stringify(userInfo));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue