perf(shell): trim render snapshot work
This commit is contained in:
@@ -32,7 +32,7 @@ impl Render for ElyShell {
|
||||
appearance,
|
||||
));
|
||||
match active_tab_from_snapshot(&snapshot) {
|
||||
Some(active_tab) => self.render_browser(snapshot, active_tab, window, cx),
|
||||
Some(active_tab) => self.render_browser(&snapshot, active_tab, window, cx),
|
||||
None => render_error("active tab missing from snapshot".to_string()),
|
||||
}
|
||||
}
|
||||
@@ -70,19 +70,19 @@ fn resolve_color_mode(
|
||||
}
|
||||
}
|
||||
|
||||
fn active_tab_from_snapshot(snapshot: &BrowserSnapshot) -> Option<BrowserTab> {
|
||||
snapshot.tabs.iter().find(|tab| tab.id() == &snapshot.active_tab_id).cloned()
|
||||
fn active_tab_from_snapshot(snapshot: &BrowserSnapshot) -> Option<&BrowserTab> {
|
||||
snapshot.tabs.iter().find(|tab| tab.id() == &snapshot.active_tab_id)
|
||||
}
|
||||
|
||||
impl ElyShell {
|
||||
fn render_browser(
|
||||
&mut self,
|
||||
snapshot: BrowserSnapshot,
|
||||
active_tab: BrowserTab,
|
||||
snapshot: &BrowserSnapshot,
|
||||
active_tab: &BrowserTab,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> AnyElement {
|
||||
let sidebar_width = match active_sidebar_width(&snapshot) {
|
||||
let sidebar_width = match active_sidebar_width(snapshot) {
|
||||
Ok(sidebar_width) => sidebar_width,
|
||||
Err(message) => return render_error(message),
|
||||
};
|
||||
@@ -129,21 +129,21 @@ impl ElyShell {
|
||||
.gap(px(spacing::SIDEBAR_MAIN_GAP))
|
||||
.flex()
|
||||
.child(self.render_sidebar(
|
||||
&snapshot,
|
||||
snapshot,
|
||||
sidebar_width,
|
||||
sidebar_collapsed,
|
||||
sidebar_hidden,
|
||||
cx,
|
||||
))
|
||||
.child(self.render_main_pane(
|
||||
&snapshot,
|
||||
&active_tab,
|
||||
snapshot,
|
||||
active_tab,
|
||||
sidebar_collapsed,
|
||||
window,
|
||||
cx,
|
||||
)),
|
||||
)
|
||||
.when(hover_expanded, |el| el.child(self.render_hidden_sidebar_overlay(&snapshot, cx)))
|
||||
.when(hover_expanded, |el| el.child(self.render_hidden_sidebar_overlay(snapshot, cx)))
|
||||
// Workspace popover only makes sense when the picker pill is
|
||||
// visible — i.e. the sidebar is expanded. Compact/hidden
|
||||
// modes don't render the trigger, so showing the disclosure
|
||||
@@ -151,9 +151,9 @@ impl ElyShell {
|
||||
.when(self.workspace_picker_open && !sidebar_collapsed && !sidebar_hidden, |el| {
|
||||
let anchor = WorkspaceDisclosureAnchor::solve(sidebar_width);
|
||||
el.child(render_workspace_disclosure_backdrop(cx))
|
||||
.child(render_workspace_disclosure(&snapshot, anchor, cx))
|
||||
.child(render_workspace_disclosure(snapshot, anchor, cx))
|
||||
})
|
||||
.children(render_command_overlay(self, &snapshot, cx))
|
||||
.children(render_command_overlay(self, snapshot, cx))
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
|
||||
@@ -408,10 +408,16 @@ impl BrowserCore {
|
||||
pub fn snapshot(&self) -> Result<BrowserSnapshot, CoreError> {
|
||||
let active_space = self.active_space()?;
|
||||
let active_profile = self.active_profile()?;
|
||||
let tabs = self.visible_tabs();
|
||||
let pinned_tabs = tabs
|
||||
.iter()
|
||||
.filter(|tab| tab.flags().pinned && !tab.flags().favorite)
|
||||
.cloned()
|
||||
.collect();
|
||||
|
||||
Ok(BrowserSnapshot {
|
||||
favorites: self.favorites(),
|
||||
pinned_tabs: self.pinned_tabs(),
|
||||
pinned_tabs,
|
||||
archived_tabs: self.archived_tabs.clone(),
|
||||
bookmarks: self.visible_bookmarks(),
|
||||
notes: self.visible_notes(),
|
||||
@@ -431,7 +437,7 @@ impl BrowserCore {
|
||||
trashed_spaces: self.trashed_spaces.clone(),
|
||||
profiles: self.profiles.clone(),
|
||||
sync_status: self.sync_status(),
|
||||
tabs: self.visible_tabs(),
|
||||
tabs,
|
||||
active_tab_id: self.active_tab_id.clone(),
|
||||
active_space_id: self.active_space_id.clone(),
|
||||
active_profile_id: self.active_profile_id.clone(),
|
||||
@@ -477,15 +483,6 @@ impl BrowserCore {
|
||||
self.tabs.iter().filter(|tab| tab.flags().favorite).cloned().collect()
|
||||
}
|
||||
|
||||
fn pinned_tabs(&self) -> Vec<BrowserTab> {
|
||||
tab_order::sorted_tabs(
|
||||
self.tabs
|
||||
.iter()
|
||||
.filter(|tab| tab.space_id() == &self.active_space_id)
|
||||
.filter(|tab| tab.flags().pinned && !tab.flags().favorite),
|
||||
)
|
||||
}
|
||||
|
||||
fn visible_tabs(&self) -> Vec<BrowserTab> {
|
||||
tab_order::sorted_tabs(
|
||||
self.tabs.iter().filter(|tab| tab.space_id() == &self.active_space_id),
|
||||
|
||||
Reference in New Issue
Block a user