Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
add type to list_recordings
Brendan Allane3801cbebcde
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex 81db87e0e..b8f593823 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -1564,13 +1564,39 @@ struct RecordingMetaChanged {id: String,}+#[derive(Serialize, specta::Type)]+pub struct RecordingMetaWithType {+ #[serde(flatten)]+ pub inner: RecordingMeta,+ pub r#type: RecordingType,+}++impl RecordingMetaWithType {+ fn new(inner: RecordingMeta) -> Self {+ Self {+ r#type: match &inner.inner {+ RecordingMetaInner::Studio(_) => RecordingType::Studio,+ RecordingMetaInner::Instant(_) => RecordingType::Instant,+ },+ inner,+ }+ }+}++#[derive(Serialize, specta::Type)]+#[serde(rename_all = "camelCase")]+pub enum RecordingType {+ Studio,+ Instant,+}+#[tauri::command(async)]#[specta::specta]fn get_recording_meta(app: AppHandle,id: String,file_type: String,-) -> Result<RecordingMeta, String> {+) -> Result<RecordingMetaWithType, String> {let meta_path = match file_type.as_str() {"recording" => recording_path(&app, &id),"screenshot" => screenshot_path(&app, &id),@@ -1578,12 +1604,15 @@ fn get_recording_meta(};RecordingMeta::load_for_project(&meta_path)+ .map(RecordingMetaWithType::new).map_err(|e| format!("Failed to load recording meta: {}", e))}#[tauri::command]#[specta::specta]-fn list_recordings(app: AppHandle) -> Result<Vec<(String, PathBuf, RecordingMeta)>, String> {+fn list_recordings(+ app: AppHandle,+) -> Result<Vec<(String, PathBuf, RecordingMetaWithType)>, String> {let recordings_dir = recordings_path(&app);// First check if directory exists@@ -1656,7 +1685,7 @@ fn list_screenshots(app: AppHandle) -> Result<Vec<(String, PathBuf, RecordingMetlet id = path.file_stem()?.to_str()?.to_string();let meta =match get_recording_meta(app.clone(), id.clone(), "screenshot".to_string()) {- Ok(meta) => meta,+ Ok(meta) => meta.inner,Err(_) => return None, // Skip this entry if metadata can't be loaded};diff --git a/apps/desktop/src/routes/(window-chrome)/settings/recordings.tsx b/apps/desktop/src/routes/(window-chrome)/settings/recordings.tsxindex 13a73536e..130b1145e 100644--- a/apps/desktop/src/routes/(window-chrome)/settings/recordings.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings/recordings.tsx@@ -2,25 +2,28 @@ import { createQuery } from "@tanstack/solid-query";import { For, ParentProps, Show, Suspense, createSignal } from "solid-js";import { convertFileSrc } from "@tauri-apps/api/core";-import { commands, events, type RecordingMeta } from "~/utils/tauri";+import {+ commands,+ events,+ RecordingMetaWithType,+ type RecordingMeta,+} from "~/utils/tauri";import { trackEvent } from "~/utils/analytics";import Tooltip from "@corvu/tooltip";-type MediaEntry = {+type Recording = {+ meta: RecordingMetaWithType;id: string;path: string;prettyName: string;- isNew: boolean;thumbnailPath: string;};export default function Recordings() {- const fetchRecordings = createQuery(() => ({+ const recordings = createQuery(() => ({queryKey: ["recordings"],queryFn: async () => {- const result = await commands- .listRecordings()- .catch(() => [] as [string, string, RecordingMeta][]);+ const result = await commands.listRecordings().catch(() => [] as const);const recordings = await Promise.all(result.map(async (file) => {@@ -28,10 +31,10 @@ export default function Recordings() {const thumbnailPath = `${path}/screenshots/display.jpg`;return {+ meta,id,path,prettyName: meta.pretty_name,- isNew: false,thumbnailPath,};})@@ -40,7 +43,7 @@ export default function Recordings() {},}));- const handleRecordingClick = (recording: MediaEntry) => {+ const handleRecordingClick = (recording: Recording) => {trackEvent("recording_view_clicked", { recording_id: recording.id });events.newStudioRecordingAdded.emit({ path: recording.path });};@@ -64,14 +67,14 @@ export default function Recordings() {<div class="flex-1 overflow-y-auto"><ul class="p-[0.625rem] flex flex-col gap-[0.5rem] w-full text-[--text-primary]"><Show- when={fetchRecordings.data && fetchRecordings.data.length > 0}+ when={recordings.data && recordings.data.length > 0}fallback={<p class="text-center text-[--text-tertiary]">No recordings found</p>}>- <For each={fetchRecordings.data}>+ <For each={recordings.data}>{(recording) => (<RecordingItemrecording={recording}@@ -89,7 +92,7 @@ export default function Recordings() {}function RecordingItem(props: {- recording: MediaEntry;+ recording: Recording;onClick: () => void;onOpenFolder: () => void;onOpenEditor: () => void;diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex 3b54b363b..c0246b12c 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -107,13 +107,13 @@ async uploadExportedVideo(videoId: string, mode: UploadMode) : Promise<UploadResasync uploadScreenshot(screenshotPath: string) : Promise<UploadResult> {return await TAURI_INVOKE("upload_screenshot", { screenshotPath });},-async getRecordingMeta(id: string, fileType: string) : Promise<RecordingMeta> {+async getRecordingMeta(id: string, fileType: string) : Promise<RecordingMetaWithType> {return await TAURI_INVOKE("get_recording_meta", { id, fileType });},async saveFileDialog(fileName: string, fileType: string) : Promise<string | null> {return await TAURI_INVOKE("save_file_dialog", { fileName, fileType });},-async listRecordings() : Promise<([string, string, RecordingMeta])[]> {+async listRecordings() : Promise<([string, string, RecordingMetaWithType])[]> {return await TAURI_INVOKE("list_recordings");},async listScreenshots() : Promise<([string, string, RecordingMeta])[]> {@@ -276,11 +276,13 @@ export type ProjectConfiguration = { aspectRatio: AspectRatio | null; backgroundexport type ProjectRecordings = { segments: SegmentRecordings[] }export type RecordingMeta = (StudioRecordingMeta | InstantRecordingMeta) & { pretty_name: string; sharing?: SharingMeta | null }export type RecordingMetaChanged = { id: string }+export type RecordingMetaWithType = ((StudioRecordingMeta | InstantRecordingMeta) & { pretty_name: string; sharing?: SharingMeta | null }) & { type: RecordingType }export type RecordingMode = "studio" | "instant"export type RecordingOptions = { captureTarget: ScreenCaptureTarget; audioInputName: string | null; cameraLabel: string | null; captureSystemAudio?: boolean; mode: RecordingMode }export type RecordingOptionsChanged = nullexport type RecordingStarted = nullexport type RecordingStopped = { path: string }+export type RecordingType = "studio" | "instant"export type RenderFrameEvent = { frame_number: number; fps: number; resolution_base: XY<number> }export type RenderProgress = { type: "Starting"; total_frames: number } | { type: "EstimatedTotalFrames"; total_frames: number } | { type: "FrameRendered"; current_frame: number }export type RequestNewScreenshot = null