mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-06 15:30:27 +03:00
add listener clearing, camel case es lint rule exception, remove unneeded else statements
This commit is contained in:
parent
0b70ce7591
commit
7dcd43c64f
1 changed files with 11 additions and 16 deletions
|
|
@ -146,21 +146,15 @@ export function CallProvider({ children }: CallProviderProps) {
|
|||
(roomId: string | null, clientWidgetApi: ClientWidgetApi | null) => {
|
||||
if (activeClientWidgetApi && activeClientWidgetApi !== clientWidgetApi) {
|
||||
logger.debug(`CallContext: Cleaning up listeners for previous clientWidgetApi instance.`);
|
||||
activeClientWidgetApi.removeAllListeners();
|
||||
}
|
||||
|
||||
if (roomId && clientWidgetApi) {
|
||||
logger.debug(`CallContext: Registering active clientWidgetApi for room ${roomId}.`);
|
||||
setActiveClientWidgetApi(clientWidgetApi, roomId);
|
||||
} else if (roomId === activeClientWidgetApiRoomId || roomId === null) {
|
||||
logger.debug(
|
||||
`CallContext: Clearing active clientWidgetApi for room ${activeClientWidgetApiRoomId}.`
|
||||
);
|
||||
setActiveClientWidgetApi(null, null);
|
||||
resetMediaState();
|
||||
} else {
|
||||
logger.debug(
|
||||
`CallContext: Ignoring clientWidgetApi registration/clear request for room ${roomId}, as current clientWidgetApi belongs to ${activeClientWidgetApiRoomId}.`
|
||||
);
|
||||
}
|
||||
},
|
||||
[activeClientWidgetApi, activeClientWidgetApiRoomId, setActiveClientWidgetApi, resetMediaState]
|
||||
|
|
@ -177,22 +171,19 @@ export function CallProvider({ children }: CallProviderProps) {
|
|||
const registerViewedClientWidgetApi = useCallback(
|
||||
(roomId: string | null, clientWidgetApi: ClientWidgetApi | null) => {
|
||||
if (viewedClientWidgetApi && viewedClientWidgetApi !== clientWidgetApi) {
|
||||
logger.error(`CallContext: Cleaning up listeners for previous clientWidgetApi instance.`);
|
||||
logger.debug(`CallContext: Cleaning up listeners for previous clientWidgetApi instance.`);
|
||||
viewedClientWidgetApi.removeAllListeners();
|
||||
viewedClientWidgetApi.stop();
|
||||
}
|
||||
|
||||
if (roomId && clientWidgetApi) {
|
||||
logger.error(`CallContext: Registering viewed clientWidgetApi for room ${roomId}.`);
|
||||
logger.debug(`CallContext: Registering viewed clientWidgetApi for room ${roomId}.`);
|
||||
setViewedClientWidgetApi(clientWidgetApi, roomId);
|
||||
} else if (roomId === viewedClientWidgetApiRoomId || roomId === null) {
|
||||
logger.error(
|
||||
logger.debug(
|
||||
`CallContext: Clearing viewed clientWidgetApi for room ${viewedClientWidgetApiRoomId}.`
|
||||
);
|
||||
setViewedClientWidgetApi(null, null);
|
||||
//resetMediaState();
|
||||
} else {
|
||||
logger.debug(
|
||||
`CallContext: Ignoring clientWidgetApi registration/clear request for room ${roomId}, as current clientWidgetApi belongs to ${viewedClientWidgetApiRoomId}.`
|
||||
);
|
||||
}
|
||||
},
|
||||
[viewedClientWidgetApi, viewedClientWidgetApiRoomId, setViewedClientWidgetApi]
|
||||
|
|
@ -223,7 +214,10 @@ export function CallProvider({ children }: CallProviderProps) {
|
|||
`CallContext: Received media state update from widget in room ${activeCallRoomId}:`,
|
||||
ev.detail
|
||||
);
|
||||
const { audio_enabled, video_enabled } = ev.detail.data;
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
const { audio_enabled, video_enabled } = ev.detail.data ?? {};
|
||||
|
||||
if (typeof audio_enabled === 'boolean' && audio_enabled !== isAudioEnabled) {
|
||||
logger.debug(`CallContext: Updating audio enabled state from widget: ${audio_enabled}`);
|
||||
setIsAudioEnabledState(audio_enabled);
|
||||
|
|
@ -232,6 +226,7 @@ export function CallProvider({ children }: CallProviderProps) {
|
|||
logger.debug(`CallContext: Updating video enabled state from widget: ${video_enabled}`);
|
||||
setIsVideoEnabledState(video_enabled);
|
||||
}
|
||||
/* eslint-enable camelcase */
|
||||
};
|
||||
|
||||
const handleOnScreenStateUpdate = (ev: CustomEvent) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue