From ffe084f0fde149c0a95a602ca669e563d50711c8 Mon Sep 17 00:00:00 2001 From: Iason Paraskevopoulos Date: Mon, 25 Aug 2025 19:30:42 +0100 Subject: [PATCH 1/9] improvement: fix viewing window closing delay When a user trantitioned from controller to sharer, the viewing window was open until the track update event was reaching the user. This is hidden now by hiding the viewing window when a screenshare is requested. --- tauri/src-tauri/src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tauri/src-tauri/src/main.rs b/tauri/src-tauri/src/main.rs index a582189..6d37640 100644 --- a/tauri/src-tauri/src/main.rs +++ b/tauri/src-tauri/src/main.rs @@ -28,8 +28,6 @@ use std::time::Duration; #[cfg(any(target_os = "windows", target_os = "linux"))] use tauri::PhysicalPosition; -//testab - #[tauri::command] async fn screenshare( app: tauri::AppHandle, @@ -38,6 +36,16 @@ async fn screenshare( resolution: Extent, ) -> bool { log::info!("screenshare: content: {content:?}, token: {token}, resolution: {resolution:?}"); + /* + * If the user was previously a controller, we need to hide the viewing + * window, to hide the delay from requesting the screen share to + * screen share starting and the viewing window automatically being closed. + */ + let window = app.get_webview_window("screenshare"); + if let Some(window) = window { + log::info!("screenshare: closing window"); + let _ = window.hide(); + } let data = app.state::>(); let mut data = data.lock().unwrap(); From 70fcd65810ca072fd748e4a03e5ff1a6cb2f3850 Mon Sep 17 00:00:00 2001 From: Iason Paraskevopoulos Date: Mon, 25 Aug 2025 19:34:52 +0100 Subject: [PATCH 2/9] improvement: merge isController and isSharer to one --- tauri/src/components/ui/call-banner.tsx | 5 +- tauri/src/components/ui/call-center.tsx | 106 +++++++----------- .../ui/participant-row-wo-livekit.tsx | 5 +- tauri/src/store/store.ts | 9 +- tauri/src/windows/contentPicker/main.tsx | 14 +-- tauri/src/windows/main-window/app.tsx | 1 - tauri/src/windows/main-window/tabs/Rooms.tsx | 5 +- tauri/src/windows/screensharing/main.tsx | 1 - 8 files changed, 56 insertions(+), 90 deletions(-) diff --git a/tauri/src/components/ui/call-banner.tsx b/tauri/src/components/ui/call-banner.tsx index c9acf5f..ca4a34a 100644 --- a/tauri/src/components/ui/call-banner.tsx +++ b/tauri/src/components/ui/call-banner.tsx @@ -2,7 +2,7 @@ import toast from "react-hot-toast"; import { HiMiniPhoneArrowDownLeft, HiMiniPhoneXMark } from "react-icons/hi2"; import { Button } from "./button"; -import useStore from "@/store/store"; +import useStore, { ParticipantRole } from "@/store/store"; import { useCallback, useEffect } from "react"; import { socketService } from "@/services/socket"; import { TWebSocketMessage } from "@/payloads"; @@ -60,8 +60,7 @@ export const CallBanner = ({ callerId, toastId }: { callerId: string; toastId: s ...data.payload, timeStarted: new Date(), hasAudioEnabled: true, - isSharer: false, - isController: false, + role: ParticipantRole.NONE, isRemoteControlEnabled: true, }); diff --git a/tauri/src/components/ui/call-center.tsx b/tauri/src/components/ui/call-center.tsx index 969b723..8257963 100644 --- a/tauri/src/components/ui/call-center.tsx +++ b/tauri/src/components/ui/call-center.tsx @@ -1,6 +1,6 @@ import { formatDistanceToNow } from "date-fns"; import { HiMiniComputerDesktop, HiOutlineMicrophone, HiOutlinePhoneXMark } from "react-icons/hi2"; -import useStore, { CallState } from "@/store/store"; +import useStore, { CallState, ParticipantRole } from "@/store/store"; import { useKrispNoiseFilter } from "@livekit/components-react/krisp"; import { Separator } from "@/components/ui/separator"; import { ToggleIconButton } from "@/components/ui/toggle-icon-button"; @@ -83,7 +83,7 @@ export function ConnectedActions({ token }: { token: string }) { sounds.callAccepted.play(); // Clear call tokens - if (callTokens.isSharer) { + if (callTokens.role === ParticipantRole.SHARER) { tauriUtils.stopSharing(); } tauriUtils.endCallCleanup(); @@ -101,33 +101,13 @@ export function ConnectedActions({ token }: { token: string }) { }); }, [callTokens, setCallTokens]); - const handleControllerChange = useCallback( - (value: boolean) => { - if (!callTokens) return; - - setCallTokens({ - ...callTokens, - isController: value, - isSharer: !value, - isRemoteControlEnabled: true, - }); - }, - [callTokens], - ); - - const handleIsSharerChange = useCallback( - (value: boolean) => { - if (!callTokens) return; - - setCallTokens({ - ...callTokens, - isSharer: value, - isController: !value, - isRemoteControlEnabled: true, - }); - }, - [callTokens], - ); + const handleRoleChange = useCallback((value: ParticipantRole) => { + if (!callTokens) return; + setCallTokens({ + ...callTokens, + role: value, + }); + }, [callTokens]); // Stop call when teammate disconnects useEffect(() => { @@ -142,8 +122,7 @@ export function ConnectedActions({ token }: { token: string }) { <> {/* */}
- {callTokens?.isController && ( + {callTokens?.role === ParticipantRole.CONTROLLER && (