Skip to content

Commit 428bb0e

Browse files
Delete on backend after closing window (#1029)
* delete on backend after closing window * remove w-full for scrolling * make it actually --------- Co-authored-by: ameer2468 <[email protected]>
1 parent b8339a4 commit 428bb0e

File tree

7 files changed

+32
-12
lines changed

7 files changed

+32
-12
lines changed

apps/desktop/src-tauri/src/lib.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub struct NewStudioRecordingAdded {
285285
path: PathBuf,
286286
}
287287

288-
#[derive(specta::Type, tauri_specta::Event, Debug, Clone)]
288+
#[derive(specta::Type, tauri_specta::Event, Debug, Clone, Serialize)]
289289
pub struct RecordingDeleted {
290290
#[allow(unused)]
291291
path: PathBuf,
@@ -1688,6 +1688,27 @@ async fn get_system_audio_waveforms(
16881688
Ok(out)
16891689
}
16901690

1691+
#[tauri::command]
1692+
#[specta::specta]
1693+
async fn editor_delete_project(
1694+
app: tauri::AppHandle,
1695+
editor_instance: WindowEditorInstance,
1696+
window: tauri::Window,
1697+
) -> Result<(), String> {
1698+
let _ = window.close();
1699+
1700+
tokio::time::sleep(std::time::Duration::from_millis(20)).await;
1701+
1702+
let path = editor_instance.0.project_path.clone();
1703+
drop(editor_instance);
1704+
1705+
let _ = tokio::fs::remove_dir_all(&path).await;
1706+
1707+
RecordingDeleted { path }.emit(&app);
1708+
1709+
Ok(())
1710+
}
1711+
16911712
// keep this async otherwise opening windows may hang on windows
16921713
#[tauri::command]
16931714
#[specta::specta]
@@ -1899,6 +1920,7 @@ pub async fn run(recording_logging_handle: LoggingHandle) {
18991920
target_select_overlay::close_target_select_overlays,
19001921
target_select_overlay::display_information,
19011922
target_select_overlay::get_window_icon,
1923+
editor_delete_project
19021924
])
19031925
.events(tauri_specta::collect_events![
19041926
RecordingOptionsChanged,

apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
4040
};
4141

4242
return (
43-
<div class="flex flex-col w-full h-full custom-scroll">
43+
<div class="flex flex-col h-full custom-scroll">
4444
<div class="p-4 space-y-4">
4545
<div class="flex flex-col pb-4 border-b border-gray-2">
4646
<h2 class="text-lg font-medium text-gray-12">

apps/desktop/src/routes/(window-chrome)/settings/general.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
372372
};
373373

374374
return (
375-
<div class="flex flex-col w-full h-full custom-scroll">
375+
<div class="flex flex-col h-full custom-scroll">
376376
<div class="p-4 space-y-6">
377377
<AppearanceSection
378378
currentTheme={settings.theme ?? "system"}

apps/desktop/src/routes/(window-chrome)/settings/hotkeys.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function Inner(props: { initialStore: HotkeysStore | null }) {
9494
] satisfies Array<keyof typeof ACTION_TEXT>;
9595

9696
return (
97-
<div class="flex flex-col flex-1 p-4 w-full h-full custom-scroll">
97+
<div class="flex flex-col flex-1 p-4 h-full custom-scroll">
9898
<div class="flex flex-col pb-4 border-b border-gray-2">
9999
<h2 class="text-lg font-medium text-gray-12">Shortcuts</h2>
100100
<p class="text-sm text-gray-10 w-full max-w-[500px]">

apps/desktop/src/routes/(window-chrome)/settings/license.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function Page() {
2323
const queryClient = useQueryClient();
2424

2525
return (
26-
<div class="flex overflow-y-auto relative flex-col gap-3 items-center p-4 mx-auto w-full h-full custom-scroll">
26+
<div class="flex relative flex-col gap-3 items-center p-4 mx-auto h-full custom-scroll">
2727
<Switch fallback={<CommercialLicensePurchase />}>
2828
<Match when={license.data?.type === "pro" && license.data}>
2929
<div class="flex justify-center items-center w-full h-screen">

apps/desktop/src/routes/editor/Header.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,10 @@ export function Header() {
7272
{ostype() === "macos" && <div class="h-full w-[4rem]" />}
7373
<EditorButton
7474
onClick={async () => {
75-
const currentWindow = getCurrentWindow();
76-
if (!editorInstance.path) return;
7775
if (!(await ask("Are you sure you want to delete this recording?")))
7876
return;
79-
await remove(editorInstance.path, {
80-
recursive: true,
81-
});
82-
events.recordingDeleted.emit({ path: editorInstance.path });
83-
await currentWindow.close();
77+
78+
await commands.editorDeleteProject();
8479
}}
8580
tooltipText="Delete recording"
8681
leftIcon={<IconCapTrash class="w-5" />}

apps/desktop/src/utils/tauri.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ async displayInformation(displayId: string) : Promise<DisplayInformation> {
262262
},
263263
async getWindowIcon(windowId: string) : Promise<string | null> {
264264
return await TAURI_INVOKE("get_window_icon", { windowId });
265+
},
266+
async editorDeleteProject() : Promise<void> {
267+
await TAURI_INVOKE("editor_delete_project");
265268
}
266269
}
267270

0 commit comments

Comments
 (0)