update issue panel

This commit is contained in:
2026-08-17 11:22:52 +07:00
parent 9f484ea98d
commit 1159252dda
13 changed files with 308 additions and 124 deletions
+1 -1
View File
@@ -9,6 +9,6 @@ pub mod status;
pub use addr::{RepoAddr, repo_addr};
pub use clone_url::{CloneTarget, parse_clone_url};
pub use deletions::Deletions;
pub use model::Announcement;
pub use model::{activity_subject, Announcement};
pub use state::parse_state;
pub use status::{RepoStatus, references_root, resolve_status};
+24
View File
@@ -26,6 +26,30 @@ pub struct Announcement {
pub hashtags: Vec<String>,
}
/// Subject of a NIP-34 issue or pull request event: the `subject` tag,
/// falling back to the first non-empty line of the content.
pub fn activity_subject(event: &Event) -> SharedString {
let subject = event
.tags
.iter()
.find_map(|tag| match Nip34Tag::parse(tag.as_slice()) {
Ok(Nip34Tag::Subject(subject)) => Some(subject),
_ => None,
});
subject
.map(SharedString::from)
.or_else(|| {
event
.content
.lines()
.map(str::trim)
.find(|line| !line.is_empty())
.map(SharedString::from)
})
.unwrap_or(SharedString::from("Untitled"))
}
impl Announcement {
/// Parse a kind `30617` event. Returns `None` if the kind is wrong or the `d` tag is missing.
pub fn from_event(event: &Event) -> Option<Self> {