mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Optimize project panel subscriptions (#8846)
The project panel now both observes all the project updates and subscribes to project events it's interested in. The observing handler updates the list of visible entries on any notification, which looks pretty excessive. This PR removes the observer completely, and adds missing event handlers to the subscription, thus removing unnecessary work. Release Notes: - N/A
This commit is contained in:
parent
78fa596839
commit
d7b5c883fe
@ -166,13 +166,7 @@ impl ProjectPanel {
|
||||
fn new(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) -> View<Self> {
|
||||
let project = workspace.project().clone();
|
||||
let project_panel = cx.new_view(|cx: &mut ViewContext<Self>| {
|
||||
cx.observe(&project, |this, _, cx| {
|
||||
this.update_visible_entries(None, cx);
|
||||
cx.notify();
|
||||
})
|
||||
.detach();
|
||||
let focus_handle = cx.focus_handle();
|
||||
|
||||
cx.on_focus(&focus_handle, Self::focus_in).detach();
|
||||
|
||||
cx.subscribe(&project, |this, project, event, cx| match event {
|
||||
@ -193,6 +187,10 @@ impl ProjectPanel {
|
||||
this.update_visible_entries(None, cx);
|
||||
cx.notify();
|
||||
}
|
||||
project::Event::WorktreeUpdatedEntries(_, _) | project::Event::WorktreeAdded => {
|
||||
this.update_visible_entries(None, cx);
|
||||
cx.notify();
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
.detach();
|
||||
|
Loading…
Reference in New Issue
Block a user