mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 14:20:42 +08:00
Omit issue body from list responses
The issues list shipped each issue's full root comment (body) over IPC, but the teaser never renders it, only the detail view does. Make Issue.body optional and add an Issue::summary constructor that skips it; list_issues now builds summaries while issue_by_id keeps the full body.
This commit is contained in:
@@ -10,7 +10,7 @@ export type Issue = {
|
||||
title: string;
|
||||
state: State;
|
||||
assignees: Array<Author>;
|
||||
body: Comment<Never>;
|
||||
body?: Comment<Never>;
|
||||
commentCount: number;
|
||||
labels: Array<string>;
|
||||
timestamp: number;
|
||||
|
||||
@@ -23,7 +23,11 @@ pub struct Issue {
|
||||
title: String,
|
||||
state: cobs::issue::State,
|
||||
assignees: Vec<cobs::Author>,
|
||||
body: cobs::thread::Comment,
|
||||
// Omitted from list responses, which only need teaser data; populated
|
||||
// when fetching a single issue.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
body: Option<cobs::thread::Comment>,
|
||||
#[ts(type = "number")]
|
||||
comment_count: usize,
|
||||
#[ts(as = "Vec<String>")]
|
||||
@@ -36,6 +40,18 @@ impl Issue {
|
||||
pub fn new(id: &issue::IssueId, issue: &issue::Issue, aliases: &impl AliasStore) -> Self {
|
||||
let (root_oid, root_comment) = issue.root();
|
||||
|
||||
Self {
|
||||
body: Some(cobs::thread::Comment::<cobs::Never>::new(
|
||||
*root_oid,
|
||||
root_comment.clone(),
|
||||
aliases,
|
||||
)),
|
||||
..Self::summary(id, issue, aliases)
|
||||
}
|
||||
}
|
||||
|
||||
/// Teaser variant for list responses; omits the issue body.
|
||||
pub fn summary(id: &issue::IssueId, issue: &issue::Issue, aliases: &impl AliasStore) -> Self {
|
||||
Self {
|
||||
id: id.to_string(),
|
||||
author: cobs::Author::new(issue.author().id(), aliases),
|
||||
@@ -45,11 +61,7 @@ impl Issue {
|
||||
.assignees()
|
||||
.map(|did| cobs::Author::new(did, aliases))
|
||||
.collect::<Vec<_>>(),
|
||||
body: cobs::thread::Comment::<cobs::Never>::new(
|
||||
*root_oid,
|
||||
root_comment.clone(),
|
||||
aliases,
|
||||
),
|
||||
body: None,
|
||||
comment_count: issue.replies().count(),
|
||||
labels: issue.labels().cloned().collect::<Vec<_>>(),
|
||||
timestamp: issue.timestamp(),
|
||||
|
||||
@@ -39,7 +39,7 @@ pub trait Issues: Profile {
|
||||
None => {
|
||||
let content = issues
|
||||
.into_iter()
|
||||
.map(|(id, issue)| cobs::issue::Issue::new(&id, &issue, aliases))
|
||||
.map(|(id, issue)| cobs::issue::Issue::summary(&id, &issue, aliases))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Ok::<_, Error>(cobs::PaginatedQuery {
|
||||
@@ -54,7 +54,7 @@ pub trait Issues: Profile {
|
||||
.into_iter()
|
||||
.skip(cursor)
|
||||
.take(take)
|
||||
.map(|(id, issue)| cobs::issue::Issue::new(&id, &issue, aliases))
|
||||
.map(|(id, issue)| cobs::issue::Issue::summary(&id, &issue, aliases))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Ok::<_, Error>(cobs::PaginatedQuery {
|
||||
|
||||
+24
-22
@@ -361,33 +361,35 @@
|
||||
allowedToEdit={roles.isDelegateOrAuthor(
|
||||
config.publicKey,
|
||||
repo.delegates.map(delegate => delegate.did),
|
||||
issue.body.author.did,
|
||||
issue.author.did,
|
||||
)}
|
||||
title={issue.title}
|
||||
cobId={issue.id} />
|
||||
</div>
|
||||
|
||||
<div class="issue-body">
|
||||
<CommentComponent
|
||||
rid={repo.rid}
|
||||
currentUserNid={config.publicKey}
|
||||
id={issue.id}
|
||||
lastEdit={issue.body.edits.length > 1
|
||||
? issue.body.edits.at(-1)
|
||||
: undefined}
|
||||
author={issue.body.author}
|
||||
caption="opened"
|
||||
reactions={issue.body.reactions}
|
||||
timestamp={issue.body.edits.slice(-1)[0].timestamp}
|
||||
body={issue.body.edits.slice(-1)[0].body}
|
||||
editComment={roles.isDelegateOrAuthor(
|
||||
config.publicKey,
|
||||
repo.delegates.map(delegate => delegate.did),
|
||||
issue.body.author.did,
|
||||
) && partial(editComment, issue.body.id)}
|
||||
reactOnComment={partial(reactOnComment, issue.body.id)}>
|
||||
</CommentComponent>
|
||||
</div>
|
||||
{#if issue.body}
|
||||
<div class="issue-body">
|
||||
<CommentComponent
|
||||
rid={repo.rid}
|
||||
currentUserNid={config.publicKey}
|
||||
id={issue.id}
|
||||
lastEdit={issue.body.edits.length > 1
|
||||
? issue.body.edits.at(-1)
|
||||
: undefined}
|
||||
author={issue.body.author}
|
||||
caption="opened"
|
||||
reactions={issue.body.reactions}
|
||||
timestamp={issue.body.edits.slice(-1)[0].timestamp}
|
||||
body={issue.body.edits.slice(-1)[0].body}
|
||||
editComment={roles.isDelegateOrAuthor(
|
||||
config.publicKey,
|
||||
repo.delegates.map(delegate => delegate.did),
|
||||
issue.body.author.did,
|
||||
) && partial(editComment, issue.body.id)}
|
||||
reactOnComment={partial(reactOnComment, issue.body.id)}>
|
||||
</CommentComponent>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<Discussion
|
||||
cobId={issue.id}
|
||||
|
||||
Reference in New Issue
Block a user