Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(desktop-gpui): refresh every library view and the tray after deleting a recording

Aditya Garud65e8cc3079bb
diff --git a/apps/desktop-gpui/src/app_windows.rs b/apps/desktop-gpui/src/app_windows.rs
index 3d1efb924..830cdc22b 100644
--- a/apps/desktop-gpui/src/app_windows.rs
+++ b/apps/desktop-gpui/src/app_windows.rs
@@ -6874,6 +6874,7 @@ pub fn refresh_library_after_delete(cx: &mut App) {
.update(cx, |view, window, cx| view.refresh_recordings(window, cx))
.ok();
}
+ crate::tray::refresh_previous(cx);
}
fn close_controls(session: &Entity<RecordingSession>, cx: &mut App) {
diff --git a/apps/desktop-gpui/src/main_window.rs b/apps/desktop-gpui/src/main_window.rs
index 36774a880..bc12bbba9 100644
--- a/apps/desktop-gpui/src/main_window.rs
+++ b/apps/desktop-gpui/src/main_window.rs
@@ -4949,7 +4949,7 @@ impl MainWindow {
window: &mut Window,
cx: &mut Context<Self>,
) {
- cx.spawn_in(window, async move |this, cx| {
+ cx.spawn_in(window, async move |_, cx| {
if !crate::platform::confirm_dialog(
"Cap",
"Are you sure you want to delete this recording?",
@@ -4969,10 +4969,8 @@ impl MainWindow {
tracing::error!(path = %path.display(), "deleting the recording failed: {error}");
return;
}
- this.update_in(cx, |this, window, cx| {
- this.refresh_library(LibraryKind::Recordings, window, cx);
- })
- .ok();
+ cx.update(|_, cx| app_windows::refresh_library_after_delete(cx))
+ .ok();
})
.detach();
}
diff --git a/apps/desktop-gpui/src/settings_window.rs b/apps/desktop-gpui/src/settings_window.rs
index 7f76cf303..e57635008 100644
--- a/apps/desktop-gpui/src/settings_window.rs
+++ b/apps/desktop-gpui/src/settings_window.rs
@@ -1190,7 +1190,7 @@ impl SettingsWindow {
/// thread, which is where `NSAlert` has to run, so the task is both the
/// right thread and the right borrow state.
fn delete_recording(&mut self, path: PathBuf, window: &mut Window, cx: &mut Context<Self>) {
- cx.spawn_in(window, async move |this, cx| {
+ cx.spawn_in(window, async move |_, cx| {
let confirmed = crate::platform::confirm_dialog(
"Cap",
"Are you sure you want to delete this recording?",
@@ -1214,7 +1214,7 @@ impl SettingsWindow {
}
tracing::info!(path = %path.display(), "deleted a recording");
- this.update_in(cx, |this, window, cx| this.refresh_recordings(window, cx))
+ cx.update(|_, cx| crate::app_windows::refresh_library_after_delete(cx))
.ok();
})
.detach();