chore: rework pull request detail into a split layout
This commit is contained in:
@@ -41,6 +41,32 @@ pub struct IssueDetailView {
|
||||
}
|
||||
|
||||
impl IssueDetailView {
|
||||
pub fn new(store: Entity<RepoStore>, issue_id: EventId, cx: &mut Context<Self>) -> Self {
|
||||
let comment_input = InputState::builder().multiline().build(cx);
|
||||
let directory = ProfileDirectory::new(cx);
|
||||
let weak = cx.entity().downgrade();
|
||||
|
||||
let subscription = cx.observe(&store, |this, _store, cx| {
|
||||
this.track_participants(cx);
|
||||
cx.notify();
|
||||
});
|
||||
|
||||
cx.defer(move |cx| {
|
||||
log_dropped(weak.update(cx, |this, cx| {
|
||||
this.track_participants(cx);
|
||||
}));
|
||||
});
|
||||
|
||||
Self {
|
||||
store,
|
||||
issue_id,
|
||||
comment_input,
|
||||
directory,
|
||||
scroll_handle: ScrollHandle::new(),
|
||||
_subscription: subscription,
|
||||
}
|
||||
}
|
||||
|
||||
/// Opens the issue's detail as the main panel and its sidebar in the split pane.
|
||||
pub fn open(
|
||||
workspace: &WeakEntity<AppRoot>,
|
||||
@@ -83,32 +109,6 @@ impl IssueDetailView {
|
||||
}));
|
||||
}
|
||||
|
||||
pub fn new(store: Entity<RepoStore>, issue_id: EventId, cx: &mut Context<Self>) -> Self {
|
||||
let comment_input = InputState::builder().multiline().build(cx);
|
||||
let directory = ProfileDirectory::new(cx);
|
||||
let weak = cx.entity().downgrade();
|
||||
|
||||
let subscription = cx.observe(&store, |this, _store, cx| {
|
||||
this.track_participants(cx);
|
||||
cx.notify();
|
||||
});
|
||||
|
||||
cx.defer(move |cx| {
|
||||
log_dropped(weak.update(cx, |this, cx| {
|
||||
this.track_participants(cx);
|
||||
}));
|
||||
});
|
||||
|
||||
Self {
|
||||
store,
|
||||
issue_id,
|
||||
comment_input,
|
||||
directory,
|
||||
scroll_handle: ScrollHandle::new(),
|
||||
_subscription: subscription,
|
||||
}
|
||||
}
|
||||
|
||||
/// Track the issue author, everyone who commented and the repository owner.
|
||||
fn track_participants(&mut self, cx: &mut Context<Self>) {
|
||||
let store = self.store.read(cx);
|
||||
|
||||
@@ -6,6 +6,7 @@ use nostr::prelude::{Event, EventId};
|
||||
use signed_core::RepoStatus;
|
||||
use signed_state::RepoStore;
|
||||
use ui::avatar::Avatar;
|
||||
use ui::badge::Badge;
|
||||
use ui::button::Button;
|
||||
use ui::common::{Sizable as _, StyledExt as _, h_flex, v_flex};
|
||||
use ui::icons::{Icon, IconRole};
|
||||
@@ -82,11 +83,20 @@ pub(crate) fn comments_section(
|
||||
) -> AnyElement {
|
||||
let store = store.read(cx);
|
||||
let comments: Vec<&Event> = store.comments_of(&root).collect();
|
||||
let title = SharedString::from(format!("Discussions {}", comments.len()));
|
||||
let count = comments.len();
|
||||
|
||||
v_flex()
|
||||
.gap_4()
|
||||
.child(div().text_xs().font_semibold().child(title))
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.child(Icon::named(IconRole::Message))
|
||||
.child(div().text_sm().font_semibold().child("Discussions"))
|
||||
.child(Badge::new(
|
||||
format!("discussion-count:{root}"),
|
||||
count.to_string(),
|
||||
)),
|
||||
)
|
||||
.children(comments.iter().map(|comment| {
|
||||
let profile = directory.read(cx).profile(&comment.pubkey, cx);
|
||||
let author = profile.name();
|
||||
|
||||
Reference in New Issue
Block a user