reorganize signed_core into method-based APIs

This commit is contained in:
2026-10-03 12:03:29 +07:00
parent d00ee33eab
commit 023267001d
20 changed files with 833 additions and 697 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ use gpui_component::input::TextareaState;
use gpui_component::scroll::ScrollableElement;
use gpui_component::{ActiveTheme, StyledExt, h_flex, v_flex};
use nostr::prelude::EventId;
use signed_core::activity_subject;
use signed_core::GitEvent;
use signed_state::{ProfileStore, RepoStore};
use signed_ui::{Avatar, placeholder, status_badge};
use utils::relative_time;
@@ -103,7 +103,7 @@ impl Render for IssueDetailView {
};
(
activity_subject(issue),
issue.activity_subject(),
profile.name(),
profile.picture(),
store.status_of(issue),
+2 -2
View File
@@ -16,7 +16,7 @@ use gpui_component::{
ActiveTheme, Icon, VirtualListScrollHandle, WindowExt, h_flex, v_flex, v_virtual_list,
};
use nostr::prelude::EventId;
use signed_core::{RepoStatus, activity_subject};
use signed_core::{GitEvent, RepoStatus};
use signed_state::{ProfileStore, RepoStore};
use signed_ui::{Avatar, SegmentButton, placeholder, status_badge};
use utils::relative_time;
@@ -146,7 +146,7 @@ impl IssuesView {
fn render_row(&self, ix: usize, issue_ix: usize, cx: &mut Context<Self>) -> AnyElement {
let issue = &self.store.read(cx).issues[issue_ix];
let title = activity_subject(issue);
let title = issue.activity_subject();
let id_hex = issue.id.to_hex();
let profile = ProfileStore::global(cx).read(cx).get(&issue.pubkey);
let author = profile.name();
@@ -21,10 +21,7 @@ use gpui_component::{
v_virtual_list,
};
use nostr::prelude::{Event, EventId, Kind, Url};
use signed_core::{
RepoAddr, activity_subject, branch_name_of, clone_urls_of, current_commit_of, latest_update,
merge_base_of, pull_request_patch,
};
use signed_core::{GitEvent, PullRequest, RepoAddr};
use signed_git::{FileCommit, patch_commits, patch_diffs};
use signed_state::{Backend, ProfileStore, RepoStore, ensure_repo_mirror};
use signed_ui::{Avatar, CountBadge, placeholder, status_badge};
@@ -145,23 +142,24 @@ impl PullRequestDetailView {
.iter()
.find(|pr| pr.id == self.pr_id && pr.kind == Kind::GitPullRequest)
.map(|root| {
let update = latest_update(store.pull_requests.iter(), root);
let update = PullRequest::latest_update(store.pull_requests.iter(), root);
let tip = update
.and_then(current_commit_of)
.or_else(|| current_commit_of(root));
.and_then(GitEvent::current_commit)
.or_else(|| root.current_commit());
let base = update
.and_then(merge_base_of)
.or_else(|| merge_base_of(root));
.and_then(GitEvent::merge_base)
.or_else(|| root.merge_base());
let clone_urls = clone_urls_of(root)
let clone_urls = root
.clone_urls()
.or_else(|| store.announcement.as_ref().map(|a| a.clone.clone()))
.unwrap_or_default();
PrBinding {
description: root.content.clone(),
patch: pull_request_patch(root, store.patches.iter()),
patch: PullRequest::new(root).patch(store.patches.iter()),
tip,
base,
clone_urls,
@@ -620,9 +618,9 @@ impl PullRequestDetailView {
return div().into_any_element();
};
(
activity_subject(root),
root.activity_subject(),
store.status_of(root),
branch_name_of(root),
root.branch_name(),
root.pubkey,
)
};
@@ -14,7 +14,7 @@ use gpui_component::{
ActiveTheme, Icon, IconName, VirtualListScrollHandle, h_flex, v_flex, v_virtual_list,
};
use nostr::prelude::{EventId, Kind};
use signed_core::{RepoStatus, activity_subject};
use signed_core::{GitEvent, RepoStatus};
use signed_state::{ProfileStore, RepoStore};
use signed_ui::{Avatar, DropdownButton, SegmentButton, placeholder, status_badge};
use utils::relative_time;
@@ -159,7 +159,7 @@ impl PullRequestsView {
fn render_row(&self, ix: usize, pr_ix: usize, cx: &mut Context<Self>) -> AnyElement {
let pr = &self.store.read(cx).pull_requests[pr_ix];
let pr_id = pr.id;
let title = activity_subject(pr);
let title = pr.activity_subject();
let id_hex = pr.id.to_hex();
let age = relative_time(pr.created_at);
@@ -21,7 +21,7 @@ use gpui_component::{
v_virtual_list,
};
use nostr::prelude::*;
use signed_core::{Announcement, RepoAddr, fork_candidates};
use signed_core::{Announcement, RepoAddr};
use signed_git::{
delete_refs_with_prefix, fetch_repo_refs, fork_namespace, merge_base, refs_with_prefix,
worktree_commit_range_commits, worktree_commit_range_diff,
@@ -512,7 +512,7 @@ impl NewPullRequestView {
};
let user = Backend::global(cx).read(cx).current_user();
let announcements = RepoListStore::global(cx).read(cx).announcements.clone();
fork_candidates(&announcements, &base, euc.as_deref(), user)
Announcement::forks_in(&announcements, &base, euc.as_deref(), user)
.into_iter()
.cloned()
.collect()
+3 -3
View File
@@ -531,7 +531,7 @@ impl RepoDetailView {
.as_ref()
.map(|name| name.to_string())
.filter(|name| !name.trim().is_empty())
.unwrap_or_else(|| addr.identifier.clone());
.unwrap_or_else(|| addr.identifier().to_owned());
let name = signed_git::sanitize_path_component(&name);
if name.is_empty() {
@@ -1857,7 +1857,7 @@ fn fork_row(announcement: &Announcement, cx: &mut Context<RepoDetailView>) -> Op
.map(SharedString::from)
.unwrap_or_else(|| SharedString::from(a.id.clone()))
})
.unwrap_or_else(|| SharedString::from(addr.identifier.clone()));
.unwrap_or_else(|| SharedString::from(addr.identifier().to_owned()));
(SharedString::from(format!("Forked from {name}")), true)
}
None => (SharedString::from(upstream.display().as_str()), false),
@@ -1900,7 +1900,7 @@ impl ShareTargets {
fn from_announcement(announcement: &Announcement) -> Self {
let addr = announcement.addr();
let coordinate = addr.to_string();
let naddr = Nip19Coordinate::new(addr, announcement.relays.iter().cloned())
let naddr = Nip19Coordinate::new(addr.into(), announcement.relays.iter().cloned())
.to_bech32()
.expect("a complete coordinate always encodes to naddr");
+1 -1
View File
@@ -228,7 +228,7 @@ impl RepoListView {
.map(SharedString::from)
.unwrap_or_else(|| SharedString::from(a.id.clone()))
})
.unwrap_or_else(|| SharedString::from(addr.identifier.clone()));
.unwrap_or_else(|| SharedString::from(addr.identifier().to_owned()));
Some(SharedString::from(format!("forked from {name}")))
});