Skip to content

Commit

Permalink
use 127.0.0.1 and fix auth error
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendonovich committed Sep 13, 2024
1 parent b6b77b4 commit d38f553
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 53 deletions.
34 changes: 16 additions & 18 deletions apps/desktop/src/routes/(main)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,29 +79,28 @@ export default function () {
}
});

const windowsData = createMemo(() => windows.data ?? []);
const audioDevicesData = createMemo(() => audioDevices.data ?? []);
const camerasData = createMemo(() => cameras() ?? []);

createUpdateCheck();

return (
<div class="flex flex-col p-[1rem] gap-[0.75rem] text-[0.875rem] font-[400] bg-gray-50">
<Show when={auth() && options.data}>
{(options) => {
const selectedWindow = createMemo(() => {
const selectedWindow = () => {
const d = options().captureTarget;
if (d.type !== "window") return;
return windowsData().find((data) => data.id === d.id);
});
return windows.data?.find((data) => data.id === d.id);
};

const audioDevice = () =>
audioDevicesData().find((d) => d.name === options().audioInputName);
const audioDevice = () => {
return audioDevices.data?.find(
(d) => d.name === options().audioInputName
);
};

return (
<>
<KSelect<CaptureWindow | null>
options={windowsData()}
options={windows.data ?? []}
optionValue="id"
optionTextValue="name"
placeholder="Window"
Expand Down Expand Up @@ -185,7 +184,7 @@ export default function () {
class={topRightAnimateClasses}
>
<Show
when={windowsData().length > 0}
when={(windows.data ?? []).length > 0}
fallback={
<div class="p-2 text-gray-500">
No windows available
Expand All @@ -203,10 +202,7 @@ export default function () {
<div class="flex flex-col gap-[0.25rem] items-stretch">
<label class="text-gray-400 text-[0.875rem]">Camera</label>
<KSelect<CameraOption>
options={[
{ deviceId: "", label: "No Camera" },
...camerasData(),
]}
options={[{ deviceId: "", label: "No Camera" }, ...cameras()]}
optionValue="deviceId"
optionTextValue="label"
placeholder="No Camera"
Expand All @@ -232,8 +228,10 @@ export default function () {
>
<KSelect.Trigger class="h-[2rem] px-[0.375rem] flex flex-row gap-[0.375rem] border rounded-lg border-gray-200 w-full items-center disabled:text-gray-400 transition-colors KSelect">
<IconCapCamera class="text-gray-400 size-[1.25rem]" />
<KSelect.Value<CameraOption> class="flex-1 text-left truncate">
{(state) => <>{state.selectedOption().label}</>}
<KSelect.Value<
CameraOption | undefined
> class="flex-1 text-left truncate">
{(state) => <>{state.selectedOption()?.label}</>}
</KSelect.Value>
<button
type="button"
Expand Down Expand Up @@ -277,7 +275,7 @@ export default function () {
<div class="flex flex-col gap-[0.25rem] items-stretch">
<label class="text-gray-400">Microphone</label>
<KSelect<{ name: string }>
options={[{ name: "No Audio" }, ...audioDevicesData()]}
options={[{ name: "No Audio" }, ...(audioDevices.data ?? [])]}
optionValue="name"
optionTextValue="name"
placeholder="No Audio"
Expand Down
75 changes: 41 additions & 34 deletions apps/desktop/src/routes/permissions.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
import { cx } from "cva";
import { Button } from "@cap/ui-solid";
import { exit } from "@tauri-apps/plugin-process";

import {
commands,
OSPermission,
OSPermissionStatus,
OSPermissionsCheck,
} from "../utils/tauri";
import { commands, type OSPermissionStatus } from "../utils/tauri";
import {
createEffect,
createResource,
Suspense,
Switch,
Match,
createSignal,
Show,
} from "solid-js";
import { createTimer } from "@solid-primitives/timer";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { Transition } from "solid-transition-group";

function isPermitted(status?: OSPermissionStatus): boolean {
return status === "granted" || status === "notNeeded";
Expand Down Expand Up @@ -85,32 +78,46 @@ export default function () {
</p>
</div>
<Suspense fallback={<div class="w-full flex-1" />}>
<div class="flex flex-col items-start gap-1">
<h4 class="font-[500] text-[0.875rem]">
{currentStep().name} Permission
</h4>
<div class="w-full flex gap-2">
<Show
when={currentStepStatus() !== "denied"}
fallback={
<Button onClick={openSettings} class="flex-1">
Open Settings
<Transition
mode="outin"
enterActiveClass="transition-opacity"
exitActiveClass="transition-opacity"
enterClass="opacity-0"
exitToClass="opacity-0"
>
<Show when={currentStep()} keyed>
<div class="flex flex-col items-start gap-1">
<h4 class="font-[500] text-[0.875rem]">
{currentStep().name} Permission
</h4>
<div class="w-full flex gap-2">
<Show
when={currentStepStatus() !== "denied"}
fallback={
<Button onClick={openSettings} class="flex-1">
Open Settings
</Button>
}
>
<Button
onClick={requestPermission}
disabled={currentStepStatus() !== "empty"}
class="flex-1"
>
Grant
</Button>
</Show>
<Button
variant="secondary"
class="flex-1"
onClick={() => exit()}
>
Quit
</Button>
}
>
<Button
onClick={requestPermission}
disabled={currentStepStatus() !== "empty"}
class="flex-1"
>
Grant
</Button>
</Show>
<Button variant="secondary" class="flex-1" onClick={() => exit()}>
Quit
</Button>
</div>
</div>
</div>
</div>
</Show>
</Transition>
</Suspense>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/desktop/session/request/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function GET(req: NextRequest) {
}

const returnUrl = new URL(
`http://localhost:${port}?token=${tokenValue}&expires=${decodedToken?.exp}`
`http://127.0.0.1:${port}?token=${tokenValue}&expires=${decodedToken?.exp}`
);

return Response.redirect(returnUrl.href);
Expand Down

1 comment on commit d38f553

@vercel
Copy link

@vercel vercel bot commented on d38f553 Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.