Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Add recording actions and empty states to Target UI

Richie McIlroy052bc62d2048
diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/TargetCard.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/TargetCard.tsx
index 7f73af82e..42748b0cf 100644
--- a/apps/desktop/src/routes/(window-chrome)/new-main/TargetCard.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/new-main/TargetCard.tsx
@@ -1,9 +1,13 @@
+import { ProgressCircle } from "@cap/ui-solid";
import { convertFileSrc } from "@tauri-apps/api/core";
-import { save } from "@tauri-apps/plugin-dialog";
+import { ask, save } from "@tauri-apps/plugin-dialog";
+import { remove } from "@tauri-apps/plugin-fs";
+import * as shell from "@tauri-apps/plugin-shell";
import { cx } from "cva";
import type { ComponentProps } from "solid-js";
import { createMemo, createSignal, Show, splitProps } from "solid-js";
import toast from "solid-toast";
+import Tooltip from "~/components/Tooltip";
import {
type CaptureDisplayWithThumbnail,
type CaptureWindowWithThumbnail,
@@ -11,13 +15,18 @@ import {
type RecordingMeta,
type RecordingMetaWithMetadata,
} from "~/utils/tauri";
+import IconCapLink from "~icons/cap/link";
+import IconCapTrash from "~icons/cap/trash";
import IconLucideAppWindowMac from "~icons/lucide/app-window-mac";
import IconLucideCopy from "~icons/lucide/copy";
import IconLucideEdit from "~icons/lucide/edit";
+import IconLucideFolder from "~icons/lucide/folder";
import IconLucideImage from "~icons/lucide/image";
+import IconLucideRotateCcw from "~icons/lucide/rotate-ccw";
import IconLucideSave from "~icons/lucide/save";
import IconLucideSquarePlay from "~icons/lucide/square-play";
import IconMdiMonitor from "~icons/mdi/monitor";
+import IconPhWarningBold from "~icons/ph/warning-bold";
export type RecordingWithPath = RecordingMetaWithMetadata & { path: string };
export type ScreenshotWithPath = RecordingMeta & { path: string };
@@ -51,6 +60,10 @@ type TargetCardProps = (
| {
variant: "recording";
target: RecordingWithPath;
+ uploadProgress?: number;
+ isReuploading?: boolean;
+ onReupload?: (path: string) => void;
+ onRefetch?: () => void;
}
| {
variant: "screenshot";
@@ -71,6 +84,11 @@ export default function TargetCard(props: TargetCardProps) {
]);
const [imageExists, setImageExists] = createSignal(true);
+ const recordingProps = () => {
+ if (local.variant !== "recording") return undefined;
+ return props as Extract<TargetCardProps, { variant: "recording" }>;
+ };
+
const displayTarget = createMemo(() => {
if (local.variant !== "display") return undefined;
return local.target as CaptureDisplayWithThumbnail;
@@ -234,6 +252,61 @@ export default function TargetCard(props: TargetCardProps) {
}
};
+ const handleOpenRecordingEditor = (e: MouseEvent) => {
+ e.stopPropagation();
+ const recording = recordingTarget();
+ if (!recording) return;
+ commands.showWindow({
+ Editor: { project_path: recording.path },
+ });
+ };
+
+ const handleOpenRecordingLink = (e: MouseEvent) => {
+ e.stopPropagation();
+ const recording = recordingTarget();
+ if (!recording?.sharing) return;
+ shell.open(recording.sharing.link);
+ };
+
+ const handleOpenRecordingFolder = (e: MouseEvent) => {
+ e.stopPropagation();
+ const recording = recordingTarget();
+ if (!recording) return;
+ commands.openFilePath(recording.path);
+ };
+
+ const handleDeleteRecording = async (e: MouseEvent) => {
+ e.stopPropagation();
+ const recording = recordingTarget();
+ if (!recording) return;
+ if (!(await ask("Are you sure you want to delete this recording?"))) return;
+ await remove(recording.path, { recursive: true });
+ recordingProps()?.onRefetch?.();
+ };
+
+ const handleReupload = (e: MouseEvent) => {
+ e.stopPropagation();
+ const recording = recordingTarget();
+ if (!recording) return;
+ recordingProps()?.onReupload?.(recording.path);
+ };
+
+ const recordingUploadFailed = createMemo(() => {
+ const recording = recordingTarget();
+ if (!recording) return false;
+ return recording.upload?.state === "Failed";
+ });
+
+ const recordingFailed = createMemo(() => {
+ const recording = recordingTarget();
+ if (!recording) return false;
+ return recording.status.status === "Failed";
+ });
+
+ const getUploadProgress = () => recordingProps()?.uploadProgress;
+
+ const getIsReuploading = () => recordingProps()?.isReuploading ?? false;
+
return (
<button
type="button"
@@ -282,6 +355,16 @@ export default function TargetCard(props: TargetCardProps) {
</Show>
<div class="absolute inset-0 border opacity-60 pointer-events-none border-black/5" />
<div class="absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t to-transparent pointer-events-none from-black/40" />
+ <Show when={recordingFailed() || recordingUploadFailed()}>
+ <div class="absolute inset-0 flex items-center justify-center bg-black/75">
+ <div class="flex items-center gap-1 px-1.5 py-0.5 rounded bg-red-9/20 text-red-11">
+ <IconPhWarningBold class="size-2.5" />
+ <span class="text-[10px] font-medium">
+ {recordingFailed() ? "Recording failed" : "Upload failed"}
+ </span>
+ </div>
+ </div>
+ </Show>
</div>
<div class="flex flex-col w-full">
<div class="flex flex-row items-start gap-2 px-2 py-1.5">
@@ -332,6 +415,93 @@ export default function TargetCard(props: TargetCardProps) {
</div>
</div>
</Show>
+ <Show when={local.variant === "recording"}>
+ {(() => {
+ const recording = recordingTarget();
+ if (!recording) return null;
+ const isStudio = recording.mode === "studio";
+ const uploadFailed = recordingUploadFailed();
+ const progress = getUploadProgress();
+ const reuploading = getIsReuploading();
+ const hasProgress = progress !== undefined || reuploading;
+
+ return (
+ <div class="flex items-center justify-between px-2 pb-1.5 pt-0.5 gap-1">
+ <Show when={isStudio}>
+ <Tooltip content="Edit">
+ <div
+ role="button"
+ tabIndex={-1}
+ onClick={handleOpenRecordingEditor}
+ class="flex-1 flex items-center justify-center p-1 rounded hover:bg-gray-5 text-gray-11 hover:text-gray-12 transition-colors"
+ >
+ <IconLucideEdit class="size-3.5" />
+ </div>
+ </Tooltip>
+ </Show>
+ <Show when={!isStudio}>
+ <Show
+ when={hasProgress}
+ fallback={
+ <Tooltip
+ content={uploadFailed ? "Retry upload" : "Reupload"}
+ >
+ <div
+ role="button"
+ tabIndex={-1}
+ onClick={handleReupload}
+ class="flex-1 flex items-center justify-center p-1 rounded hover:bg-gray-5 text-gray-11 hover:text-gray-12 transition-colors"
+ >
+ <IconLucideRotateCcw class="size-3.5" />
+ </div>
+ </Tooltip>
+ }
+ >
+ <div class="flex-1 flex items-center justify-center p-1">
+ <ProgressCircle
+ variant="primary"
+ progress={progress ?? 0}
+ size="xs"
+ />
+ </div>
+ </Show>
+ </Show>
+ <Show when={recording.sharing}>
+ <Tooltip content="Open link">
+ <div
+ role="button"
+ tabIndex={-1}
+ onClick={handleOpenRecordingLink}
+ class="flex-1 flex items-center justify-center p-1 rounded hover:bg-gray-5 text-gray-11 hover:text-gray-12 transition-colors"
+ >
+ <IconCapLink class="size-3.5" />
+ </div>
+ </Tooltip>
+ </Show>
+ <Tooltip content="Open folder">
+ <div
+ role="button"
+ tabIndex={-1}
+ onClick={handleOpenRecordingFolder}
+ class="flex-1 flex items-center justify-center p-1 rounded hover:bg-gray-5 text-gray-11 hover:text-gray-12 transition-colors"
+ >
+ <IconLucideFolder class="size-3.5" />
+ </div>
+ </Tooltip>
+ <Tooltip content="Delete">
+ <div
+ role="button"
+ tabIndex={-1}
+ onClick={handleDeleteRecording}
+ class="flex-1 flex items-center justify-center p-1 rounded hover:bg-gray-5 text-gray-11 hover:text-gray-12 transition-colors"
+ >
+ <IconCapTrash class="size-3.5" />
+ </div>
+ </Tooltip>
+ </div>
+ );
+ })()}
+ </Show>
</div>
</button>
);
diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/TargetMenuGrid.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/TargetMenuGrid.tsx
index 565d8a345..9d45814b7 100644
--- a/apps/desktop/src/routes/(window-chrome)/new-main/TargetMenuGrid.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/new-main/TargetMenuGrid.tsx
@@ -1,10 +1,13 @@
import { cx } from "cva";
-import { createMemo, For, Match, Switch } from "solid-js";
+import { createMemo, For, type JSX, Match, Show, Switch } from "solid-js";
import { Transition } from "solid-transition-group";
import type {
CaptureDisplayWithThumbnail,
CaptureWindowWithThumbnail,
} from "~/utils/tauri";
+import IconLucideExternalLink from "~icons/lucide/external-link";
+import IconLucideImage from "~icons/lucide/image";
+import IconLucideSquarePlay from "~icons/lucide/square-play";
import TargetCard, {
type RecordingWithPath,
type ScreenshotWithPath,
@@ -35,10 +38,16 @@ type WindowGridProps = BaseProps<CaptureWindowWithThumbnail> & {
type RecordingGridProps = BaseProps<RecordingWithPath> & {
variant: "recording";
+ uploadProgress?: Record<string, number>;
+ reuploadingPaths?: Set<string>;
+ onReupload?: (path: string) => void;
+ onRefetch?: () => void;
+ onViewAll?: () => void;
};
type ScreenshotGridProps = BaseProps<ScreenshotWithPath> & {
variant: "screenshot";
+ onViewAll?: () => void;
};
type TargetMenuGridProps =
@@ -47,6 +56,48 @@ type TargetMenuGridProps =
| RecordingGridProps
| ScreenshotGridProps;
+function EmptyState(props: {
+ icon: JSX.Element;
+ title: string;
+ description: string;
+ action?: { label: string; onClick: () => void };
+}) {
+ return (
+ <div class="col-span-2 flex flex-col items-center justify-center py-8 px-4 text-center">
+ <div class="flex items-center justify-center size-12 rounded-full bg-gray-3 mb-3">
+ {props.icon}
+ </div>
+ <p class="text-sm font-medium text-gray-12 mb-1">{props.title}</p>
+ <p class="text-xs text-gray-10 mb-3 max-w-[200px]">{props.description}</p>
+ <Show when={props.action}>
+ {(action) => (
+ <button
+ type="button"
+ onClick={action().onClick}
+ class="flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-gray-12 bg-gray-3 rounded-lg hover:bg-gray-4 transition-colors"
+ >
+ <IconLucideExternalLink class="size-3" />
+ {action().label}
+ </button>
+ )}
+ </Show>
+ </div>
+ );
+}
+
+function ViewAllButton(props: { onClick: () => void; label: string }) {
+ return (
+ <button
+ type="button"
+ onClick={props.onClick}
+ class="col-span-2 flex items-center justify-center gap-2 py-2.5 mt-1 text-xs font-medium text-gray-11 bg-gray-3 rounded-lg hover:bg-gray-4 hover:text-gray-12 transition-colors"
+ >
+ <IconLucideExternalLink class="size-3" />
+ {props.label}
+ </button>
+ );
+}
+
export default function TargetMenuGrid(props: TargetMenuGridProps) {
const items = createMemo(() => props.targets ?? []);
const skeletonItems = createMemo(() =>
@@ -112,14 +163,56 @@ export default function TargetMenuGrid(props: TargetMenuGridProps) {
target?.focus();
};
- const defaultEmptyMessage = () =>
- props.variant === "display"
- ? "No displays found"
- : props.variant === "window"
- ? "No windows found"
- : props.variant === "recording"
- ? "No recordings found"
- : "No screenshots found";
+ const getOnViewAll = () => {
+ if (props.variant === "recording")
+ return (props as RecordingGridProps).onViewAll;
+ if (props.variant === "screenshot")
+ return (props as ScreenshotGridProps).onViewAll;
+ return undefined;
+ };
+
+ const renderEmptyState = () => {
+ const onViewAll = getOnViewAll();
+
+ if (props.variant === "recording") {
+ return (
+ <EmptyState
+ icon={<IconLucideSquarePlay class="size-5 text-gray-10" />}
+ title="No recordings yet"
+ description="Your screen recordings will appear here. Start recording to get started!"
+ action={
+ onViewAll
+ ? { label: "View All Recordings", onClick: onViewAll }
+ : undefined
+ }
+ />
+ );
+ }
+
+ if (props.variant === "screenshot") {
+ return (
+ <EmptyState
+ icon={<IconLucideImage class="size-5 text-gray-10" />}
+ title="No screenshots yet"
+ description="Your screenshots will appear here. Take a screenshot to get started!"
+ action={
+ onViewAll
+ ? { label: "View All Screenshots", onClick: onViewAll }
+ : undefined
+ }
+ />
+ );
+ }
+
+ return (
+ <div class="col-span-2 py-6 text-sm text-center text-gray-11">
+ {props.emptyMessage ??
+ (props.variant === "display"
+ ? "No displays found"
+ : "No windows found")}
+ </div>
+ );
+ };
return (
<div
@@ -143,11 +236,7 @@ export default function TargetMenuGrid(props: TargetMenuGridProps) {
{() => <TargetCardSkeleton class="w-full" />}
</For>
</Match>
- <Match when={isEmpty()}>
- <div class="col-span-2 py-6 text-sm text-center text-gray-11">
- {props.emptyMessage ?? defaultEmptyMessage()}
- </div>
- </Match>
+ <Match when={isEmpty()}>{renderEmptyState()}</Match>
<Match when={items().length > 0}>
<Switch>
<Match when={props.variant === "display"}>
@@ -224,34 +313,75 @@ export default function TargetMenuGrid(props: TargetMenuGridProps) {
{(() => {
const recordingProps = props as RecordingGridProps;
return (
- <For each={items() as RecordingWithPath[]}>
- {(item, index) => (
- <Transition
- appear
- enterActiveClass="transition duration-200"
- enterClass="scale-95 opacity-0"
- enterToClass="scale-100 opacity-100"
- exitActiveClass="transition duration-200"
- exitClass="scale-100"
- exitToClass="scale-95"
- >
- <div
- style={{ "transition-delay": `${index() * 100}ms` }}
- >
- <TargetCard
- variant="recording"
- target={item}
- onClick={() => recordingProps.onSelect?.(item)}
- disabled={recordingProps.disabled}
- onKeyDown={handleKeyDown}
- class="w-full"
- data-target-menu-card="true"
- highlightQuery={recordingProps.highlightQuery}
- />
- </div>
- </Transition>
- )}
- </For>
+ <>
+ <For each={items() as RecordingWithPath[]}>
+ {(item, index) => {
+ const videoId = () => {
+ const upload = item.upload;
+ if (!upload) return undefined;
+ if (
+ upload.state === "MultipartUpload" ||
+ upload.state === "SinglePartUpload"
+ ) {
+ return upload.video_id;
+ }
+ return undefined;
+ };
+ const progress = () => {
+ const id = videoId();
+ if (!id || !recordingProps.uploadProgress)
+ return undefined;
+ return recordingProps.uploadProgress[id];
+ };
+ const isReuploading = () => {
+ return (
+ recordingProps.reuploadingPaths?.has(item.path) ??
+ false
+ );
+ };
+ return (
+ <Transition
+ appear
+ enterActiveClass="transition duration-200"
+ enterClass="scale-95 opacity-0"
+ enterToClass="scale-100 opacity-100"
+ exitActiveClass="transition duration-200"
+ exitClass="scale-100"
+ exitToClass="scale-95"
+ >
+ <div
+ style={{
+ "transition-delay": `${index() * 100}ms`,
+ }}
+ >
+ <TargetCard
+ variant="recording"
+ target={item}
+ onClick={() => recordingProps.onSelect?.(item)}
+ disabled={recordingProps.disabled}
+ onKeyDown={handleKeyDown}
+ class="w-full"
+ data-target-menu-card="true"
+ highlightQuery={recordingProps.highlightQuery}
+ uploadProgress={progress()}
+ isReuploading={isReuploading()}
+ onReupload={recordingProps.onReupload}
+ onRefetch={recordingProps.onRefetch}
+ />
+ </div>
+ </Transition>
+ );
+ }}
+ </For>
+ <Show when={recordingProps.onViewAll}>
+ {(onViewAll) => (
+ <ViewAllButton
+ onClick={onViewAll()}
+ label="View All Recordings"
+ />
+ )}
+ </Show>
+ </>
);
})()}
</Match>
@@ -259,34 +389,44 @@ export default function TargetMenuGrid(props: TargetMenuGridProps) {
{(() => {
const screenshotProps = props as ScreenshotGridProps;
return (
- <For each={items() as ScreenshotWithPath[]}>
- {(item, index) => (
- <Transition
- appear
- enterActiveClass="transition duration-200"
- enterClass="scale-95 opacity-0"
- enterToClass="scale-100 opacity-100"
- exitActiveClass="transition duration-200"
- exitClass="scale-100"
- exitToClass="scale-95"
- >
- <div
- style={{ "transition-delay": `${index() * 100}ms` }}
+ <>
+ <For each={items() as ScreenshotWithPath[]}>
+ {(item, index) => (
+ <Transition
+ appear
+ enterActiveClass="transition duration-200"
+ enterClass="scale-95 opacity-0"
+ enterToClass="scale-100 opacity-100"
+ exitActiveClass="transition duration-200"
+ exitClass="scale-100"
+ exitToClass="scale-95"
>
- <TargetCard
- variant="screenshot"
- target={item}
- onClick={() => screenshotProps.onSelect?.(item)}
- disabled={screenshotProps.disabled}
- onKeyDown={handleKeyDown}
- class="w-full"
- data-target-menu-card="true"
- highlightQuery={screenshotProps.highlightQuery}
- />
- </div>
- </Transition>
- )}
- </For>
+ <div
+ style={{ "transition-delay": `${index() * 100}ms` }}
+ >
+ <TargetCard
+ variant="screenshot"
+ target={item}
+ onClick={() => screenshotProps.onSelect?.(item)}
+ disabled={screenshotProps.disabled}
+ onKeyDown={handleKeyDown}
+ class="w-full"
+ data-target-menu-card="true"
+ highlightQuery={screenshotProps.highlightQuery}
+ />
+ </div>
+ </Transition>
+ )}
+ </For>
+ <Show when={screenshotProps.onViewAll}>
+ {(onViewAll) => (
+ <ViewAllButton
+ onClick={onViewAll()}
+ label="View All Screenshots"
+ />
+ )}
+ </Show>
+ </>
);
})()}
</Match>
diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
index ce6dc37d0..cb9c5e475 100644
--- a/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx
@@ -2,16 +2,13 @@ import { Button } from "@cap/ui-solid";
import { createEventListener } from "@solid-primitives/event-listener";
import { useNavigate } from "@solidjs/router";
import { createMutation, queryOptions, useQuery } from "@tanstack/solid-query";
+import { Channel } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
import {
getAllWebviewWindows,
WebviewWindow,
} from "@tauri-apps/api/webviewWindow";
-import {
- getCurrentWindow,
- LogicalSize,
- primaryMonitor,
-} from "@tauri-apps/api/window";
+import { getCurrentWindow, LogicalSize } from "@tauri-apps/api/window";
import * as dialog from "@tauri-apps/plugin-dialog";
import { type as ostype } from "@tauri-apps/plugin-os";
import * as shell from "@tauri-apps/plugin-shell";
@@ -27,14 +24,14 @@ import {
Show,
Suspense,
} from "solid-js";
-import { reconcile } from "solid-js/store";
-// Removed solid-motionone in favor of solid-transition-group
+import { createStore, produce, reconcile } from "solid-js/store";
import { Transition } from "solid-transition-group";
import Mode from "~/components/Mode";
import Tooltip from "~/components/Tooltip";
import { Input } from "~/routes/editor/ui";
import { authStore, generalSettingsStore } from "~/store";
import { createSignInMutation } from "~/utils/auth";
+import { createTauriEventListener } from "~/utils/createEventListener";
import {
createCameraMutation,
createCurrentRecordingQuery,
@@ -55,9 +52,10 @@ import {
type CaptureWindowWithThumbnail,
commands,
type DeviceOrModelID,
- type RecordingMetaWithMetadata,
+ events,
type RecordingTargetMode,
type ScreenCaptureTarget,
+ type UploadProgress,
} from "~/utils/tauri";
import IconCapLogoFull from "~icons/cap/logo-full";
import IconCapLogoFullDark from "~icons/cap/logo-full-dark";
@@ -84,12 +82,7 @@ import TargetDropdownButton from "./TargetDropdownButton";
import TargetMenuGrid from "./TargetMenuGrid";
import TargetTypeButton from "./TargetTypeButton";
-function getWindowSize() {
- return {
- width: 290,
- height: 310,
- };
-}
+const WINDOW_SIZE = { width: 290, height: 310 } as const;
const findCamera = (cameras: CameraInfo[], id: DeviceOrModelID) => {
return cameras.find((c) => {
@@ -155,6 +148,10 @@ type TargetMenuPanelProps =
targets?: RecordingWithPath[];
onSelect: (target: RecordingWithPath) => void;
onViewAll: () => void;
+ uploadProgress?: Record<string, number>;
+ reuploadingPaths?: Set<string>;
+ onReupload?: (path: string) => void;
+ onRefetch?: () => void;
}
| {
variant: "screenshot";
@@ -261,51 +258,25 @@ function TargetMenuPanel(props: TargetMenuPanelProps & SharedTargetMenuProps) {
<span class="font-medium text-gray-12">Back</span>
</div>
<div class="relative flex-1 min-w-0 h-[36px] flex items-center">
- <Show
- when={
- props.variant === "recording" || props.variant === "screenshot"
- }
- fallback={
- <>
- <IconLucideSearch class="absolute left-2 top-[48%] -translate-y-1/2 pointer-events-none size-3 text-gray-10" />
- <Input
- type="search"
- class="py-2 pl-6 h-full"
- value={search()}
- onInput={(event) => setSearch(event.currentTarget.value)}
- onKeyDown={(event) => {
- if (event.key === "Escape" && search()) {
- event.preventDefault();
- setSearch("");
- }
- }}
- placeholder={placeholder}
- autoCapitalize="off"
- autocorrect="off"
- autocomplete="off"
- spellcheck={false}
- aria-label={placeholder}
- />
- </>
- }
- >
- <button
- type="button"
- class="flex w-full items-center justify-start h-full pl-2 text-xs text-gray-11 transition-colors rounded hover:bg-gray-3 hover:text-gray-12 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-9 focus-visible:ring-offset-2 focus-visible:ring-offset-gray-1"
- onClick={() => {
- if ("onViewAll" in props) props.onViewAll();
- }}
- >
- {props.variant === "recording" ? (
- <IconLucideSquarePlay class="mr-2 size-3" />
- ) : (
- <IconLucideImage class="mr-2 size-3" />
- )}
- {props.variant === "recording"
- ? "View All Recordings"
- : "View All Screenshots"}
- </button>
- </Show>
+ <IconLucideSearch class="absolute left-2 top-[48%] -translate-y-1/2 pointer-events-none size-3 text-gray-10" />
+ <Input
+ type="search"
+ class="py-2 pl-6 h-full"
+ value={search()}
+ onInput={(event) => setSearch(event.currentTarget.value)}
+ onKeyDown={(event) => {
+ if (event.key === "Escape" && search()) {
+ event.preventDefault();
+ setSearch("");
+ }
+ }}
+ placeholder={placeholder}
+ autoCapitalize="off"
+ autocorrect="off"
+ autocomplete="off"
+ spellcheck={false}
+ aria-label={placeholder}
+ />
</div>
</div>
<div class="flex flex-col flex-1 min-h-0 pt-4">
@@ -342,6 +313,11 @@ function TargetMenuPanel(props: TargetMenuPanelProps & SharedTargetMenuProps) {
disabled={props.disabled}
highlightQuery={trimmedSearch()}
emptyMessage={trimmedSearch() ? noResultsMessage : undefined}
+ uploadProgress={props.uploadProgress}
+ reuploadingPaths={props.reuploadingPaths}
+ onReupload={props.onReupload}
+ onRefetch={props.onRefetch}
+ onViewAll={props.onViewAll}
/>
) : (
<TargetMenuGrid
@@ -353,6 +329,7 @@ function TargetMenuPanel(props: TargetMenuPanelProps & SharedTargetMenuProps) {
disabled={props.disabled}
highlightQuery={trimmedSearch()}
emptyMessage={trimmedSearch() ? noResultsMessage : undefined}
+ onViewAll={props.onViewAll}
/>
)}
</div>
@@ -458,6 +435,46 @@ function Page() {
}));
const recordings = useQuery(() => listRecordings);
+
+ const [uploadProgress, setUploadProgress] = createStore<
+ Record<string, number>
+ >({});
+ const [reuploadingPaths, setReuploadingPaths] = createSignal<Set<string>>(
+ new Set(),
+ );
+
+ createTauriEventListener(events.uploadProgressEvent, (e) => {
+ setUploadProgress(e.video_id, (Number(e.uploaded) / Number(e.total)) * 100);
+ if (e.uploaded === e.total) {
+ setUploadProgress(
+ produce((s) => {
+ delete s[e.video_id];
+ }),
+ );
+ }
+ });
+
+ createTauriEventListener(events.recordingDeleted, () => recordings.refetch());
+
+ const handleReupload = async (path: string) => {
+ setReuploadingPaths((prev) => new Set([...prev, path]));
+ try {
+ await commands.uploadExportedVideo(
+ path,
+ "Reupload",
+ new Channel<UploadProgress>(() => {}),
+ null,
+ );
+ } finally {
+ setReuploadingPaths((prev) => {
+ const next = new Set(prev);
+ next.delete(path);
+ return next;
+ });
+ recordings.refetch();
+ }
+ };
+
const screenshots = useQuery(() =>
queryOptions<ScreenshotWithPath[]>({
queryKey: ["screenshots"],
@@ -594,23 +611,24 @@ function Page() {
const currentWindow = getCurrentWindow();
- const size = getWindowSize();
- currentWindow.setSize(new LogicalSize(size.width, size.height));
+ currentWindow.setSize(
+ new LogicalSize(WINDOW_SIZE.width, WINDOW_SIZE.height),
+ );
const unlistenFocus = currentWindow.onFocusChanged(
({ payload: focused }) => {
if (focused) {
- const size = getWindowSize();
-
- currentWindow.setSize(new LogicalSize(size.width, size.height));
+ currentWindow.setSize(
+ new LogicalSize(WINDOW_SIZE.width, WINDOW_SIZE.height),
+ );
}
},
);
const unlistenResize = currentWindow.onResized(() => {
- const size = getWindowSize();
-
- currentWindow.setSize(new LogicalSize(size.width, size.height));
+ currentWindow.setSize(
+ new LogicalSize(WINDOW_SIZE.width, WINDOW_SIZE.height),
+ );
});
commands.updateAuthPlan();
@@ -619,9 +637,6 @@ function Page() {
(await unlistenFocus)?.();
(await unlistenResize)?.();
});
-
- const monitor = await primaryMonitor();
- if (!monitor) return;
});
const cameras = useQuery(() => listVideoDevices);
@@ -1126,6 +1141,10 @@ function Page() {
});
getCurrentWindow().hide();
}}
+ uploadProgress={uploadProgress}
+ reuploadingPaths={reuploadingPaths()}
+ onReupload={handleReupload}
+ onRefetch={() => recordings.refetch()}
/>
) : (
<TargetMenuPanel