update repo list

This commit is contained in:
2026-08-08 08:44:02 +07:00
parent de9673e8fb
commit 322f6f60bc
12 changed files with 226 additions and 20 deletions
+1
View File
@@ -8,6 +8,7 @@ publish.workspace = true
assets = { path = "../assets" }
signed_core = { path = "../signed_core" }
signed_state = { path = "../signed_state" }
utils = { path = "../utils" }
gpui.workspace = true
gpui-component.workspace = true
+63 -4
View File
@@ -6,7 +6,8 @@ use gpui::{
use gpui_component::dock::{Panel, PanelEvent};
use gpui_component::{ActiveTheme, StyledExt};
use signed_core::Announcement;
use signed_state::{ProfileStore, RepoListStore};
use signed_state::{ProfileStore, RepoListStore, Timestamp};
use utils::relative_time;
/// Browse all announced repositories (works anonymously).
pub struct RepoListView {
@@ -27,7 +28,12 @@ impl RepoListView {
}
}
fn render_card(&self, announcement: &Announcement, cx: &mut App) -> AnyElement {
fn render_card(
&self,
announcement: &Announcement,
last_activity: Option<Timestamp>,
cx: &mut App,
) -> AnyElement {
let name = announcement
.name
.clone()
@@ -40,9 +46,41 @@ impl RepoListView {
let description = announcement.description.clone().unwrap_or_default();
let mut hashtags: Vec<AnyElement> = announcement
.hashtags
.iter()
.take(3)
.map(|tag| {
div()
.text_xs()
.text_color(cx.theme().muted_foreground)
.whitespace_nowrap()
.child(SharedString::from(format!("#{tag}")))
.into_any_element()
})
.collect();
let remaining = announcement.hashtags.len().saturating_sub(3);
if remaining > 0 {
hashtags.push(
div()
.text_xs()
.text_color(cx.theme().muted_foreground)
.whitespace_nowrap()
.child(SharedString::from(format!("+{remaining}")))
.into_any_element(),
);
}
let activity = last_activity
.map(relative_time)
.map(|label| SharedString::from(format!("Updated {label}")))
.unwrap_or_default();
div()
.v_flex()
.h(px(60.))
.h(px(78.))
.w_full()
.justify_center()
.gap_1()
@@ -78,6 +116,24 @@ impl RepoListView {
.text_ellipsis()
.child(description),
)
.child(
div()
.h_flex()
.gap_2()
.items_center()
.overflow_hidden()
.children(hashtags)
.child(
div()
.flex_1()
.h_flex()
.justify_end()
.text_xs()
.text_color(cx.theme().muted_foreground)
.whitespace_nowrap()
.child(activity),
),
)
.into_any_element()
}
}
@@ -103,6 +159,7 @@ impl Focusable for RepoListView {
impl Render for RepoListView {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let announcements = self.store.read(cx).announcements.clone();
let last_activity = self.store.read(cx).last_activity.clone();
let has_announcements = !announcements.is_empty();
let count = announcements.len();
@@ -147,7 +204,9 @@ impl Render for RepoListView {
let mut items = vec![];
for ix in range {
items.push(this.render_card(&announcements[ix], cx));
let announcement: &Announcement = &announcements[ix];
let activity = last_activity.get(&announcement.addr()).copied();
items.push(this.render_card(announcement, activity, cx));
}
items