This commit is contained in:
2026-09-01 09:04:51 +07:00
parent ab2277ee83
commit d4f9203707
3 changed files with 109 additions and 85 deletions
+29 -14
View File
@@ -444,9 +444,9 @@ impl RepoDetailView {
return;
}
if let Ok(Some((branches, tags, current_branch, head_commit))) = refresh {
let branches: Vec<SharedString> =
branches.into_iter().map(Into::into).collect();
let tags: Vec<SharedString> = tags.into_iter().map(Into::into).collect();
let branches: Vec<SharedString> = branches.iter().map(Into::into).collect();
let tags: Vec<SharedString> = tags.iter().map(Into::into).collect();
this.branch_select.update(cx, |state, cx| {
state.set_items(SearchableVec::from(branches), window, cx);
if let Some(branch) = current_branch {
@@ -454,14 +454,22 @@ impl RepoDetailView {
state.set_selected_values(&[branch], window, cx);
}
});
this.tag_select.update(cx, |state, cx| {
state.set_items(SearchableVec::from(tags), window, cx);
});
let new_head_commit = head_commit.as_ref().map(|c| &c.id);
let current_head_commit = this.head_commit.as_ref().map(|c| &c.id);
let head_changed = new_head_commit != current_head_commit;
this.head_commit = head_commit;
// The fetch may have brought new commits: reload the list.
this.all_commits = None;
this.loading_all_commits = false;
this.load_all_commits(cx);
if head_changed || this.all_commits.is_none() {
this.all_commits = None;
this.loading_all_commits = false;
this.load_all_commits(cx);
}
cx.notify();
}
})?;
@@ -472,8 +480,8 @@ impl RepoDetailView {
self.tasks.push(task);
}
/// Apply the loaded repository data: explorer tree, README preview, ref
/// selectors and HEAD commit, then start the commit-list walk.
/// Apply the loaded repository data: explorer tree, README preview,
/// ref selectors and HEAD commit, then start the commit-list walk.
fn apply_repo_data(&mut self, data: RepoData, window: &mut Window, cx: &mut Context<Self>) {
let RepoData {
tree,
@@ -496,10 +504,11 @@ impl RepoDetailView {
state.set_items(tree_items(tree, false), cx);
});
// Populate the branch/tag selectors with the local refs, selecting
// the branch HEAD points to.
// Populate the branch/tag selectors with the local refs,
// selecting the branch HEAD points to.
let branches: Vec<SharedString> = branches.into_iter().map(Into::into).collect();
let tags: Vec<SharedString> = tags.into_iter().map(Into::into).collect();
self.branch_select.update(cx, |state, cx| {
state.set_items(SearchableVec::from(branches), window, cx);
if let Some(branch) = current_branch {
@@ -507,11 +516,13 @@ impl RepoDetailView {
state.set_selected_values(&[branch], window, cx);
}
});
self.tag_select.update(cx, |state, cx| {
state.set_items(SearchableVec::from(tags), window, cx);
});
self.load_all_commits(cx);
if let Some((path, bytes)) = readme_path.zip(readme) {
self.readme_name = Some(path.to_string_lossy().into());
self.load_commit(&path.to_string_lossy(), cx);
@@ -521,8 +532,8 @@ impl RepoDetailView {
}
}
/// Clone the repository into a folder chosen by the user (outside the
/// cache), then open the new clone in the system file manager.
/// Clone the repository into a folder chosen by the user (outside the cache),
/// then open the new clone in the system file manager.
fn clone_to_folder(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if self.cloning {
return;
@@ -1240,7 +1251,11 @@ impl RepoDetailView {
.filter(|nip05| !nip05.trim().is_empty());
let key = (source.event_id, nip05);
if self.header_cache.as_ref().is_none_or(|cache| cache.key != key) {
if self
.header_cache
.as_ref()
.is_none_or(|cache| cache.key != key)
{
let announcement = source.clone();
let share = ShareTargets::from_announcement(&announcement);
let nostr_url = nostr_clone_url(&announcement, key.1.as_deref());
@@ -80,7 +80,8 @@ pub struct PullRequestsView {
/// virtual list renders this slice. Rebuilt only when the store
/// version or the filter changes, keyed by [`Self::cache_key`].
visible_prs: Vec<usize>,
/// Header counts `(total, open, closed, draft, merged)`, rebuilt with
/// Header counts `(total, open, closed, draft, merged)` of the root
/// pull requests only (revisions are not separate PRs), rebuilt with
/// [`Self::visible_prs`].
counts: (usize, usize, usize, usize, usize),
/// Store version and filter the cached rows/counts were built from.
@@ -549,6 +550,13 @@ impl Render for PullRequestsView {
.iter()
.enumerate()
.filter_map(|(ix, pr)| {
// Kind-30620 patches are revisions of a root PR (NIP-34),
// not separate pull requests: count only root events, or
// the header counts inflate with every revision (which
// also default to `Open` in `status_of`).
if pr.kind != Kind::GitPullRequest {
return None;
}
let status = store.status_of(pr);
counts.0 += 1;
match status {
@@ -557,7 +565,7 @@ impl Render for PullRequestsView {
RepoStatus::Draft => counts.3 += 1,
RepoStatus::Applied => counts.4 += 1,
}
(pr.kind == Kind::GitPullRequest && filter.matches(status)).then_some(ix)
filter.matches(status).then_some(ix)
})
.collect();
self.counts = counts;