Skip to content

Commit

Permalink
fix: Better device selection on load
Browse files Browse the repository at this point in the history
  • Loading branch information
richiemcilroy committed Nov 26, 2024
1 parent 66bd799 commit b039741
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
27 changes: 18 additions & 9 deletions apps/desktop/src/routes/(window-chrome)/(main).tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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}
Expand Down
2 changes: 2 additions & 0 deletions apps/desktop/src/utils/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export const listAudioDevices = queryOptions({
},
reconcile: "name",
refetchInterval: 1000,
gcTime: 0,
staleTime: 0
});

export const getPermissions = queryOptions({
Expand Down

0 comments on commit b039741

Please sign in to comment.