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