add image cache

This commit is contained in:
2026-08-17 20:27:31 +07:00
parent 1159252dda
commit 37d6c3ccd6
8 changed files with 232 additions and 13 deletions
@@ -24,9 +24,11 @@ use utils::relative_time;
use super::helpers::placeholder;
/// Height of one issue row in the virtual list: two stacked text lines
/// (14px title + 12px meta, ~1.4x line height each) plus a little padding.
const ISSUE_ROW_HEIGHT: f32 = 40.;
/// Height of one issue row in the virtual list: 12px padding on top and
/// bottom, a 14px title line and a 24px meta line (the small avatar is the
/// tallest item). Gpui's default line height is phi (~1.62x), so the title
/// line is ~22.7px; the row totals ~71px.
const ISSUE_ROW_HEIGHT: f32 = 71.;
/// Panel listing all issues of a repository (no filters). The list stays
/// live by reading the store during `render`.
@@ -45,7 +47,16 @@ pub struct IssuesView {
}
impl IssuesView {
pub fn new(store: Entity<RepoStore>, repo_name: SharedString, cx: &mut Context<Self>) -> Self {
pub fn new(
store: Entity<RepoStore>,
repo_name: SharedString,
window: &mut Window,
cx: &mut Context<Self>,
) -> Self {
// Issue author avatars stay in the shared cache until the panel
// closes; free them then.
crate::image_cache::clear_on_release(&cx.entity(), window, cx);
Self {
focus_handle: cx.focus_handle(),
store,
@@ -71,7 +82,9 @@ impl IssuesView {
.h(px(ISSUE_ROW_HEIGHT))
.w_full()
.gap_4()
.px_3()
.p_3()
.border_b_1()
.border_color(cx.theme().border)
.items_start()
.child(Self::render_status(status, cx))
.child(
@@ -93,7 +106,6 @@ impl IssuesView {
.child(
h_flex()
.gap_1()
.items_center()
.child(
Avatar::new()
.name(author.clone())
@@ -102,6 +114,7 @@ impl IssuesView {
)
.child(div().child(author)),
)
.child(SharedString::from("opened"))
.child(
div()
.text_color(cx.theme().muted_foreground)
@@ -166,9 +179,7 @@ impl Panel for IssuesView {
}
fn title(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div()
.text_sm()
.child(SharedString::from(format!("{}/issues", self.repo_name)))
div().child(SharedString::from(format!("{}/issues", self.repo_name)))
}
}