diff --git a/src/components/launch/SourceSelector.tsx b/src/components/launch/SourceSelector.tsx index b0bba991..2b825c4b 100644 --- a/src/components/launch/SourceSelector.tsx +++ b/src/components/launch/SourceSelector.tsx @@ -5,7 +5,12 @@ import { useScopedT } from "@/contexts/I18nContext"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; -import { mapRawSource, type DesktopSource, type RawDesktopSource } from "./popovers/launchPopoverTypes"; +import { + mapRawSource, + isScreenSource, + isWindowSource, + type DesktopSource, +} from "./popovers/launchPopoverTypes"; import "./launchTheme.css"; import "./SourceSelector.css"; @@ -212,7 +217,7 @@ export const SourceSelector = React.memo(function SourceSelector({ thumbnailSize: { width: 160, height: 90 }, fetchWindowIcons: true, }); - setInternalSources(rawSources.map((s) => mapRawSource(s as RawDesktopSource))); + setInternalSources(rawSources.map((s) => mapRawSource(s as DesktopSource))); } catch (error) { console.error("Failed to fetch sources:", error); } finally { @@ -244,11 +249,11 @@ export const SourceSelector = React.memo(function SourceSelector({ // Split sources for internal use const internalScreenSources = useMemo( - () => internalSources.filter((s) => s.sourceType === "screen" || s.id.startsWith("screen:")), + () => internalSources.filter(isScreenSource), [internalSources], ); const internalWindowSources = useMemo( - () => internalSources.filter((s) => s.sourceType === "window" || s.id.startsWith("window:")), + () => internalSources.filter(isWindowSource), [internalSources], ); @@ -302,7 +307,7 @@ export const SourceSelector = React.memo(function SourceSelector({ const trigger = children ? ( React.isValidElement(children) ? ( - React.cloneElement(children as React.ReactElement, { + React.cloneElement(children as React.ReactElement>, { onPointerEnter: prefetchSources, onFocusCapture: prefetchSources, }) diff --git a/src/components/launch/popovers/SourcePopover.tsx b/src/components/launch/popovers/SourcePopover.tsx index 3f82dab8..5459fae1 100644 --- a/src/components/launch/popovers/SourcePopover.tsx +++ b/src/components/launch/popovers/SourcePopover.tsx @@ -1,7 +1,12 @@ import { useCallback, useMemo, type ReactNode, useState } from "react"; import { SourceSelector } from "../SourceSelector"; import { useLaunchPopoverCoordinator } from "./LaunchPopoverCoordinator"; -import { mapRawSource, type DesktopSource, type RawDesktopSource } from "./launchPopoverTypes"; +import { + mapRawSource, + isScreenSource, + isWindowSource, + type DesktopSource, +} from "./launchPopoverTypes"; const POPOVER_ID = "sources"; @@ -30,7 +35,7 @@ export function SourcePopover({ thumbnailSize: { width: 160, height: 90 }, fetchWindowIcons: true, }); - setSources(rawSources.map((s) => mapRawSource(s as RawDesktopSource))); + setSources(rawSources.map((s) => mapRawSource(s as DesktopSource))); } catch (error) { console.error("Failed to fetch sources:", error); } finally { @@ -38,14 +43,8 @@ export function SourcePopover({ } }, []); - const screenSources = useMemo( - () => sources.filter((s) => s.sourceType === "screen" || s.id.startsWith("screen:")), - [sources], - ); - const windowSources = useMemo( - () => sources.filter((s) => s.sourceType === "window" || s.id.startsWith("window:")), - [sources], - ); + const screenSources = useMemo(() => sources.filter(isScreenSource), [sources]); + const windowSources = useMemo(() => sources.filter(isWindowSource), [sources]); return (