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
This commit is contained in:
loczek 2024-06-21 07:00:46 +02:00 committed by GitHub
parent 6eb537643a
commit 3076567f6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -191,6 +191,11 @@ impl Workspace {
self.dismiss_notification(id, cx);
}
pub fn clear_all_notifications(&mut self, cx: &mut ViewContext<Self>) {
self.notifications.clear();
cx.notify();
}
fn dismiss_notification_internal(&mut self, id: &NotificationId, cx: &mut ViewContext<Self>) {
self.notifications.retain(|(existing_id, _)| {
if existing_id == id {

View File

@ -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))