From 3076567f6beea8b27637e3b5f5614838f18798e1 Mon Sep 17 00:00:00 2001 From: loczek <30776250+loczek@users.noreply.github.com> Date: Fri, 21 Jun 2024 07:00:46 +0200 Subject: [PATCH] workspace: Add clear notifications command (#13320) Release Notes: - Added the `workspace: clear all notifications` command to clear notifications ([#10761](https://github.com/zed-industries/zed/issues/10761)) https://github.com/zed-industries/zed/assets/30776250/36f2c3f3-5b5e-4f98-9418-8806ce311504 --- crates/workspace/src/notifications.rs | 5 +++++ crates/workspace/src/workspace.rs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/crates/workspace/src/notifications.rs b/crates/workspace/src/notifications.rs index 49cd2b6767..d54ec8bf9d 100644 --- a/crates/workspace/src/notifications.rs +++ b/crates/workspace/src/notifications.rs @@ -191,6 +191,11 @@ impl Workspace { self.dismiss_notification(id, cx); } + pub fn clear_all_notifications(&mut self, cx: &mut ViewContext) { + self.notifications.clear(); + cx.notify(); + } + fn dismiss_notification_internal(&mut self, id: &NotificationId, cx: &mut ViewContext) { self.notifications.retain(|(existing_id, _)| { if existing_id == id { diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 7bcf311300..acdf294aac 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -115,6 +115,7 @@ actions!( ActivateNextPane, ActivatePreviousPane, AddFolderToProject, + ClearAllNotifications, CloseAllDocks, CloseWindow, Feedback, @@ -3896,6 +3897,11 @@ impl Workspace { workspace.close_all_docks(cx); }), ) + .on_action( + cx.listener(|workspace: &mut Workspace, _: &ClearAllNotifications, cx| { + workspace.clear_all_notifications(cx); + }), + ) .on_action(cx.listener(Workspace::open)) .on_action(cx.listener(Workspace::close_window)) .on_action(cx.listener(Workspace::activate_pane_at_index))