Skip to content

Commit 101032b

Browse files
fix(ui): update WebRTCVideo component to properly animate on peer connection state (#343)
1 parent 6618ee4 commit 101032b

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

ui/src/components/WebRTCVideo.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default function WebRTCVideo() {
2828
const videoElm = useRef<HTMLVideoElement>(null);
2929
const mediaStream = useRTCStore(state => state.mediaStream);
3030
const [isPlaying, setIsPlaying] = useState(false);
31+
const peerConnectionState = useRTCStore(state => state.peerConnectionState);
3132

3233
// Store hooks
3334
const settings = useSettingsStore();
@@ -601,7 +602,10 @@ export default function WebRTCVideo() {
601602
"cursor-none":
602603
settings.mouseMode === "absolute" &&
603604
settings.isCursorHidden,
604-
"opacity-0": isVideoLoading || hdmiError,
605+
"opacity-0":
606+
isVideoLoading ||
607+
hdmiError ||
608+
peerConnectionState !== "connected",
605609
"animate-slideUpFade border border-slate-800/30 opacity-0 shadow dark:border-slate-300/20":
606610
isPlaying,
607611
},

ui/src/routes/devices.$id.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -795,14 +795,16 @@ export default function KvmIdRoute() {
795795
kvmName={deviceName || "JetKVM Device"}
796796
/>
797797

798-
<div className="flex h-full w-full overflow-hidden">
799-
<div className="pointer-events-none fixed inset-0 isolate z-20 flex h-full w-full items-center justify-center">
800-
<div className="my-2 h-full max-h-[720px] w-full max-w-[1280px] rounded-md">
798+
<div className="relative z-50 flex h-full w-full overflow-hidden">
799+
<WebRTCVideo />
800+
<div
801+
style={{ animationDuration: "500ms" }}
802+
className="pointer-events-none absolute inset-0 flex animate-slideUpFade items-center justify-center p-4 opacity-0"
803+
>
804+
<div className="relative h-full max-h-[720px] w-full max-w-[1280px] rounded-md">
801805
{!!ConnectionStatusElement && ConnectionStatusElement}
802806
</div>
803807
</div>
804-
805-
{peerConnectionState === "connected" && <WebRTCVideo />}
806808
<SidebarContainer sidebarView={sidebarView} />
807809
</div>
808810
</div>

0 commit comments

Comments
 (0)