From 2835901a642164c409dd06e4ff1bbd49ac13d78a Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Fri, 20 Oct 2023 04:43:47 +0700 Subject: [PATCH] Fix Client App [Tauri] [+] fix(exporter.tsx): fix issue with saving files in client app [Tauri] when there is a ':' in the dialog [+] fix(utils.ts): fix issue with saving files in client app [Tauri] when there is a ':' in the dialog --- app/components/exporter.tsx | 7 ++++++- app/utils.ts | 12 +++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/components/exporter.tsx b/app/components/exporter.tsx index 0a885d874..bfe8f7bbe 100644 --- a/app/components/exporter.tsx +++ b/app/components/exporter.tsx @@ -446,8 +446,13 @@ export function ImagePreviewer(props: { if (isMobile || (isApp && window.__TAURI__)) { if (isApp && window.__TAURI__) { + /** + * Fixed client app [Tauri] + * Resolved the issue where files couldn't be saved when there was a `:` in the dialog. + */ + const fileName = props.topic.replace(/:/g, ''); const result = await window.__TAURI__.dialog.save({ - defaultPath: `${props.topic}.png`, + defaultPath: `${fileName}.png`, filters: [ { name: "PNG Files", diff --git a/app/utils.ts b/app/utils.ts index acc140ac3..31b3d9a3a 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -33,12 +33,18 @@ export async function copyToClipboard(text: string) { export async function downloadAs(text: string, filename: string) { if (window.__TAURI__) { + /** + * Fixed client app [Tauri] + * Resolved the issue where files couldn't be saved when there was a `:` in the dialog. + **/ + const fileName = filename.replace(/:/g, ''); + const fileExtension = fileName.split('.').pop(); const result = await window.__TAURI__.dialog.save({ - defaultPath: `${filename}`, + defaultPath: `${fileName}`, filters: [ { - name: `${filename.split('.').pop()} files`, - extensions: [`${filename.split('.').pop()}`], + name: `${fileExtension} files`, + extensions: [`${fileExtension}`], }, { name: "All Files",