Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: Better device selection on load

Richie McIlroyb03974153068
diff --git a/apps/desktop/src/routes/(window-chrome)/(main).tsx b/apps/desktop/src/routes/(window-chrome)/(main).tsx
index bba9e7cc2..f2854b797 100644
--- a/apps/desktop/src/routes/(window-chrome)/(main).tsx
+++ b/apps/desktop/src/routes/(window-chrome)/(main).tsx
@@ -470,9 +470,13 @@ function MicrophoneSelect(props: {
const [dbs, setDbs] = createSignal<number | undefined>();
const [isInitialized, setIsInitialized] = createSignal(false);
- const value = () =>
- devices?.data?.find((d) => d.name === props.options?.audioInputName) ??
- null;
+ const value = createMemo(() => {
+ if (!props.options?.audioInputName) return null;
+ return (
+ devices.data?.find((d) => d.name === props.options!.audioInputName) ??
+ null
+ );
+ });
const requestPermission = useRequestPermission();
@@ -566,12 +570,17 @@ function MicrophoneSelect(props: {
)}
</Show>
<IconCapMicrophone class="text-gray-400 size-[1.25rem]" />
- <KSelect.Value<{
- name: string;
- }> class="flex-1 text-left truncate">
- {(state) => (
- <span>{state.selectedOption()?.name ?? "No Audio"}</span>
- )}
+ <KSelect.Value<Option> class="flex-1 text-left truncate">
+ {(state) => {
+ const selected = state.selectedOption();
+ return (
+ <span>
+ {selected?.name ??
+ props.options?.audioInputName ??
+ "No Audio"}
+ </span>
+ );
+ }}
</KSelect.Value>
<TargetSelectInfoPill
value={props.options?.audioInputName ?? null}
diff --git a/apps/desktop/src/utils/queries.ts b/apps/desktop/src/utils/queries.ts
index ce4ae1e38..a56762af4 100644
--- a/apps/desktop/src/utils/queries.ts
+++ b/apps/desktop/src/utils/queries.ts
@@ -56,6 +56,8 @@ export const listAudioDevices = queryOptions({
},
reconcile: "name",
refetchInterval: 1000,
+ gcTime: 0,
+ staleTime: 0
});
export const getPermissions = queryOptions({