From 413ce044766e86e22993d0705ffe0c1ca7bed972 Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Wed, 16 Sep 2026 09:15:17 +0700 Subject: [PATCH] cache image only when it needed --- crates/workspace/src/lib.rs | 37 +++++++++------------ crates/workspace/src/panels/contact_list.rs | 3 +- crates/workspace/src/panels/profile.rs | 3 +- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/crates/workspace/src/lib.rs b/crates/workspace/src/lib.rs index 60a3f732..c53f9fc5 100644 --- a/crates/workspace/src/lib.rs +++ b/crates/workspace/src/lib.rs @@ -9,7 +9,7 @@ use device::{DeviceEvent, DeviceRegistry}; use gpui::prelude::FluentBuilder; use gpui::{ Action, App, AppContext, Axis, Context, Entity, InteractiveElement, IntoElement, ParentElement, - Render, SharedString, Styled, Subscription, Task, Window, div, image_cache, px, retain_all, + Render, SharedString, Styled, Subscription, Task, Window, div, px, }; use nostr_sdk::prelude::*; use person::{PersonRegistry, shorten_pubkey}; @@ -773,31 +773,26 @@ impl Render for Workspace { .relative() .size_full() .child( - image_cache(retain_all("workspace")) - .relative() + v_flex() .size_full() + // Title Bar .child( - v_flex() + TitleBar::new() + .child(self.titlebar_left(cx)) + .child(self.titlebar_right(cx)), + ) + // Main + .child( + h_flex() .size_full() - // Title Bar .child( - TitleBar::new() - .child(self.titlebar_left(cx)) - .child(self.titlebar_right(cx)), + div() + .flex_shrink_0() + .h_full() + .w(SIDEBAR_WIDTH) + .child(self.sidebar.clone()), ) - // Main - .child( - h_flex() - .size_full() - .child( - div() - .flex_shrink_0() - .h_full() - .w(SIDEBAR_WIDTH) - .child(self.sidebar.clone()), - ) - .child(self.dock.clone()), - ), + .child(self.dock.clone()), ), ) // Notifications diff --git a/crates/workspace/src/panels/contact_list.rs b/crates/workspace/src/panels/contact_list.rs index b6afb557..8a0e6d18 100644 --- a/crates/workspace/src/panels/contact_list.rs +++ b/crates/workspace/src/panels/contact_list.rs @@ -5,7 +5,7 @@ use gpui::prelude::FluentBuilder; use gpui::{ AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, ParentElement, Render, SharedString, Styled, Subscription, - Task, TextAlign, Window, div, rems, + Task, TextAlign, Window, div, rems, retain_all, }; use instant::Duration; use nostr_sdk::prelude::*; @@ -297,6 +297,7 @@ impl Focusable for ContactListPanel { impl Render for ContactListPanel { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { v_flex() + .image_cache(retain_all("contact-list-panel")) .p_3() .gap_3() .w_full() diff --git a/crates/workspace/src/panels/profile.rs b/crates/workspace/src/panels/profile.rs index c9e46d93..5bee4cb3 100644 --- a/crates/workspace/src/panels/profile.rs +++ b/crates/workspace/src/panels/profile.rs @@ -4,7 +4,7 @@ use anyhow::Error; use gpui::{ AnyElement, App, AppContext, ClipboardItem, Context, Entity, EventEmitter, FocusHandle, Focusable, IntoElement, ParentElement, PathPromptOptions, Render, SharedString, Styled, Task, - Window, div, + Window, div, retain_all, }; use instant::Duration; use nostr_sdk::prelude::*; @@ -321,6 +321,7 @@ impl Render for ProfilePanel { let shorten_pkey = SharedString::from(shorten_pubkey(self.public_key, 8)); v_flex() + .image_cache(retain_all("profile-panel")) .p_3() .gap_3() .w_full()