mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
feat(voice): share the voice room across popout trees (#2399)
This commit is contained in:
1 parent
d8e0c2ec20
commit
adb9a689f0
2 files changed
+18
-5
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
import {VoiceRoomContext} from '@app/features/voice/components/VoiceRoomContext';
|
||||||
import {type RoomAudioRendererProps, RoomContext} from '@livekit/components-react';
|
import {type RoomAudioRendererProps, RoomContext} from '@livekit/components-react';
|
||||||
import type {Room} from 'livekit-client';
|
import type {Room} from 'livekit-client';
|
||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
@@ -43,13 +44,15 @@ export function VoiceLiveKitRoot({room, children}: VoiceLiveKitRootProps): React
|
|||||||
}, [components, room]);
|
}, [components, room]);
|
||||||
|
|
||||||
if (!room) {
|
if (!room) {
|
||||||
return <>{children}</>;
|
return <VoiceRoomContext.Provider value={undefined}>{children}</VoiceRoomContext.Provider>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RoomContext.Provider value={room}>
|
<VoiceRoomContext.Provider value={room}>
|
||||||
{children}
|
<RoomContext.Provider value={room}>
|
||||||
{components && <components.RoomAudioRenderer data-flx="app.app.app-wrapper.room-audio-renderer" />}
|
{children}
|
||||||
</RoomContext.Provider>
|
{components && <components.RoomAudioRenderer data-flx="app.app.app-wrapper.room-audio-renderer" />}
|
||||||
|
</RoomContext.Provider>
|
||||||
|
</VoiceRoomContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
import type {Room} from 'livekit-client';
|
||||||
|
import {createContext, useContext} from 'react';
|
||||||
|
|
||||||
|
export const VoiceRoomContext = createContext<Room | undefined>(undefined);
|
||||||
|
|
||||||
|
export function useMaybeVoiceRoom(): Room | undefined {
|
||||||
|
return useContext(VoiceRoomContext);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user