From fd90d0b830bd18bc0b029d6deae22294ee5d132e Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Tue, 12 Aug 2025 19:02:28 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(frontend)=20add=20persistence=20for?= =?UTF-8?q?=20video=20publishing=20resolution=20setting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement user choice persistence for video publishing resolution configuration to maintain user preferences across sessions. Stores selected video resolution in user settings, ensuring consistent video quality preferences without requiring reconfiguration on each visit. --- src/frontend/src/features/rooms/components/Conference.tsx | 5 +++++ .../features/rooms/livekit/hooks/usePersistentUserChoices.ts | 4 ++++ src/frontend/src/stores/userChoices.ts | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/src/frontend/src/features/rooms/components/Conference.tsx b/src/frontend/src/features/rooms/components/Conference.tsx index e5cf0684..1adc8f46 100644 --- a/src/frontend/src/features/rooms/components/Conference.tsx +++ b/src/frontend/src/features/rooms/components/Conference.tsx @@ -12,6 +12,7 @@ import { RoomOptions, supportsAdaptiveStream, supportsDynacast, + VideoPresets, } from 'livekit-client' import { keys } from '@/api/queryKeys' import { queryClient } from '@/api/queryClient' @@ -98,6 +99,9 @@ export const Conference = ({ }, videoCaptureDefaults: { deviceId: userConfig.videoDeviceId ?? undefined, + resolution: userConfig.videoPublishResolution + ? VideoPresets[userConfig.videoPublishResolution].resolution + : undefined, }, audioCaptureDefaults: { deviceId: userConfig.audioDeviceId ?? undefined, @@ -109,6 +113,7 @@ export const Conference = ({ // do not rely on the userConfig object directly as its reference may change on every render }, [ userConfig.videoDeviceId, + userConfig.videoPublishResolution, userConfig.audioDeviceId, userConfig.audioOutputDeviceId, isAdaptiveStreamSupported, diff --git a/src/frontend/src/features/rooms/livekit/hooks/usePersistentUserChoices.ts b/src/frontend/src/features/rooms/livekit/hooks/usePersistentUserChoices.ts index b62d4907..b9a90153 100644 --- a/src/frontend/src/features/rooms/livekit/hooks/usePersistentUserChoices.ts +++ b/src/frontend/src/features/rooms/livekit/hooks/usePersistentUserChoices.ts @@ -1,5 +1,6 @@ import { useSnapshot } from 'valtio' import { userChoicesStore } from '@/stores/userChoices' +import type { VideoResolution } from '@/stores/userChoices' import { ProcessorSerialized } from '@/features/rooms/livekit/components/blur' export function usePersistentUserChoices() { @@ -22,6 +23,9 @@ export function usePersistentUserChoices() { saveVideoInputDeviceId: (deviceId: string) => { userChoicesStore.videoDeviceId = deviceId }, + saveVideoPublishResolution: (resolution: VideoResolution) => { + userChoicesStore.videoPublishResolution = resolution + }, saveUsername: (username: string) => { userChoicesStore.username = username }, diff --git a/src/frontend/src/stores/userChoices.ts b/src/frontend/src/stores/userChoices.ts index 8f4834dd..56105662 100644 --- a/src/frontend/src/stores/userChoices.ts +++ b/src/frontend/src/stores/userChoices.ts @@ -6,16 +6,20 @@ import { LocalUserChoices as LocalUserChoicesLK, } from '@livekit/components-core' +export type VideoResolution = 'h720' | 'h360' | 'h180' + export type LocalUserChoices = LocalUserChoicesLK & { processorSerialized?: ProcessorSerialized noiseReductionEnabled?: boolean audioOutputDeviceId?: string + videoPublishResolution?: VideoResolution } function getUserChoicesState(): LocalUserChoices { return { noiseReductionEnabled: false, audioOutputDeviceId: 'default', // Use 'default' to match LiveKit's standard device selection behavior + videoPublishResolution: 'h720', ...loadUserChoices(), } }