From 599d6fd0074a9fcd84c83707b7bf2d63bfa3b50d Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 12 Jul 2024 14:15:27 -0400 Subject: [PATCH] Address review feedback --- src/Platform.ts | 5 +++++ src/livekit/MediaDevicesContext.tsx | 2 +- src/settings/SettingsModal.tsx | 2 +- src/settings/settings.ts | 10 +--------- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Platform.ts b/src/Platform.ts index 0e5b71f1..86f1bc57 100644 --- a/src/Platform.ts +++ b/src/Platform.ts @@ -36,3 +36,8 @@ if (/android/i.test(navigator.userAgent)) { } else { platform = "desktop"; } + +export const isFirefox = (): boolean => { + const { userAgent } = navigator; + return userAgent.includes("Firefox"); +}; diff --git a/src/livekit/MediaDevicesContext.tsx b/src/livekit/MediaDevicesContext.tsx index 31d98a54..2f654946 100644 --- a/src/livekit/MediaDevicesContext.tsx +++ b/src/livekit/MediaDevicesContext.tsx @@ -33,8 +33,8 @@ import { audioInput as audioInputSetting, audioOutput as audioOutputSetting, videoInput as videoInputSetting, - isFirefox, } from "../settings/settings"; +import { isFirefox } from "../Platform"; export interface MediaDevice { available: MediaDeviceInfo[]; diff --git a/src/settings/SettingsModal.tsx b/src/settings/SettingsModal.tsx index 05784d15..fd0b6295 100644 --- a/src/settings/SettingsModal.tsx +++ b/src/settings/SettingsModal.tsx @@ -44,8 +44,8 @@ import { useSetting, optInAnalytics as optInAnalyticsSetting, developerSettingsTab as developerSettingsTabSetting, - isFirefox, } from "./settings"; +import { isFirefox } from "../Platform"; type SettingsTab = | "audio" diff --git a/src/settings/settings.ts b/src/settings/settings.ts index 73242b56..307a557e 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -56,12 +56,6 @@ export function useSetting(setting: Setting): [T, (value: T) => void] { return [useObservableEagerState(setting.value), setting.setValue]; } -// TODO: This doesn't belong here -export const isFirefox = (): boolean => { - const { userAgent } = navigator; - return userAgent.includes("Firefox"); -}; - // null = undecided export const optInAnalytics = new Setting( "opt-in-analytics", @@ -74,9 +68,7 @@ export const useOptInAnalytics = (): [ ((value: boolean | null) => void) | null, ] => { const setting = useSetting(optInAnalytics); - if (PosthogAnalytics.instance.isEnabled()) return setting; - - return [false, null]; + return PosthogAnalytics.instance.isEnabled() ? setting : [false, null]; }; export const developerSettingsTab = new Setting(