Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Use Tauri saveFileDialog and improve logging
Richie McIlroybeee12e90691
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex 67d4b3489..799901ab0 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -3082,33 +3082,27 @@ async fn save_file_dialog() -> Result<Option<String>, String> {use tauri_plugin_dialog::DialogExt;- println!("save_file_dialog called with file_name: {file_name}, file_type: {file_type}");+ info!(file_name, file_type, "Save file dialog requested");let file_name = file_name.strip_suffix(".cap").unwrap_or(&file_name).to_string();- println!("File name after removing .cap suffix: {file_name}");let (name, extension) = match file_type.as_str() {- "recording" => {- println!("File type is recording");- ("MP4 Video", "mp4")- }- "screenshot" => {- println!("File type is screenshot");- ("PNG Image", "png")- }+ "recording" | "mp4" => ("MP4 Video", "mp4"),+ "gif" => ("GIF Image", "gif"),+ "mov" => ("MOV Video", "mov"),+ "screenshot" | "png" => ("PNG Image", "png"),_ => {- println!("Invalid file type: {file_type}");+ warn!(file_type, "Invalid save file dialog type");return Err("Invalid file type".to_string());}};- println!("Showing save dialog with name: {name}, extension: {extension}");+ info!(file_name, name, extension, "Showing save file dialog");let (tx, rx) = std::sync::mpsc::channel();- println!("Created channel for communication");app.dialog().file()@@ -3116,7 +3110,6 @@ async fn save_file_dialog(.set_file_name(file_name).add_filter(name, &[extension]).save_file(move |path| {- println!("Save file callback triggered");let _ = tx.send(path.as_ref().and_then(|p| p.as_path())@@ -3124,14 +3117,13 @@ async fn save_file_dialog();});- println!("Waiting for user selection");match rx.recv() {Ok(result) => {- println!("Save dialog result: {result:?}");+ info!(path = ?result, "Save file dialog completed");Ok(result)}Err(e) => {- println!("Error receiving result: {e}");+ warn!(error = %e, "Save file dialog failed");notifications::send_notification(&app,notifications::NotificationType::VideoSaveFailed,diff --git a/apps/desktop/src/routes/editor/ExportPage.tsx b/apps/desktop/src/routes/editor/ExportPage.tsxindex d9a3bfe05..ddc54e09b 100644--- a/apps/desktop/src/routes/editor/ExportPage.tsx+++ b/apps/desktop/src/routes/editor/ExportPage.tsx@@ -4,7 +4,7 @@ import { makePersisted } from "@solid-primitives/storage";import { createMutation } from "@tanstack/solid-query";import { Channel } from "@tauri-apps/api/core";import { CheckMenuItem, Menu } from "@tauri-apps/api/menu";-import { ask, save as saveDialog } from "@tauri-apps/plugin-dialog";+import { ask } from "@tauri-apps/plugin-dialog";import { remove } from "@tauri-apps/plugin-fs";import { type as ostype } from "@tauri-apps/plugin-os";import { cx } from "cva";@@ -575,15 +575,10 @@ export function ExportPage() {const releaseExportSession = await beginExportSessionGuard();try {const extension = exportFileExtension();- const savePath = await saveDialog({- filters: [- {- name: `${extension.toUpperCase()} filter`,- extensions: [extension],- },- ],- defaultPath: `~/Desktop/${meta().prettyName}.${extension}`,- });+ const savePath = await commands.saveFileDialog(+ `${meta().prettyName}.${extension}`,+ extension,+ );if (!savePath) {throw new SilentError("Save dialog cancelled");}