This commit is contained in:
2026-08-31 13:37:02 +07:00
parent 43ea3708d2
commit a2ef6bb1a3
8 changed files with 143 additions and 46 deletions
@@ -84,7 +84,7 @@ pub fn open(
.label("Repository name")
.description("Max 100 characters")
.required(true)
.child(Input::new(&name_input)),
.child(Input::new(&name_input).readonly(true)),
)
.child(
field()
@@ -28,7 +28,7 @@ use gpui_component::{
use nostr::prelude::{RelayUrl, ToBech32};
use signed_core::Announcement;
use signed_git::{CommitList, FileCommit};
use signed_state::{GitStore, ProfileStore, RepoStore};
use signed_state::{GitStore, LocalReposStore, ProfileStore, RepoStore};
use crate::image_cache::{MAX_IMAGES, image_cache};
use crate::pixel_avatar::PixelAvatar;
@@ -1530,6 +1530,11 @@ impl RepoDetailView {
announcement: Announcement,
cx: &mut Context<Self>,
) {
// The repository is no longer a bare local repo: drop it from the
// scan results so it leaves the sidebar's local section immediately.
if let Some(path) = self.local_path.take() {
LocalReposStore::global(cx).update(cx, |store, cx| store.remove(&path, cx));
}
let store =
cx.new(|cx| RepoStore::new(announcement.addr(), announcement.relays.clone(), cx));
// Re-render when the store refreshes (issues, PRs, statuses).
@@ -1537,7 +1542,6 @@ impl RepoDetailView {
.push(cx.observe(&store, |_this, _store, cx| cx.notify()));
self.store = Some(store);
self.initial = Some(announcement);
self.local_path = None;
cx.notify();
}
+19 -1
View File
@@ -1,3 +1,4 @@
use std::collections::HashSet;
use std::ops::Range;
use std::path::{Path, PathBuf};
use std::time::{SystemTime, UNIX_EPOCH};
@@ -18,7 +19,7 @@ use gpui_component::avatar::Avatar;
use gpui_component::button::{Button, ButtonVariants};
use gpui_component::input::InputState;
use gpui_component::{ActiveTheme, Icon, IconName, Sizable, StyledExt, h_flex, v_flex};
use signed_core::Announcement;
use signed_core::{Announcement, identifier_from_name};
use signed_state::{Backend, BackendEvent, LocalReposStore, Profile, ProfileStore, RepoListStore};
use super::{RepoDetailView, RepoListView};
@@ -250,6 +251,23 @@ impl SidebarPanel {
)
.when_some(store, |builder, store| {
let announcements = store.read(cx).announcements.clone();
// Local repositories that have already been published to
// NIP-34 are listed among the user's repositories above;
// hide them from the local section (matched by the
// identifier derived from the directory name, like the
// init dialog's default name).
let announced_ids: HashSet<String> =
announcements.iter().map(|a| a.id.clone()).collect();
let local_repos: Vec<PathBuf> = local_repos
.iter()
.filter(|path| {
let Some(name) = path.file_name() else {
return true;
};
!announced_ids.contains(&identifier_from_name(&name.to_string_lossy()))
})
.cloned()
.collect();
// One merged list: the user's NIP-34 repositories first,
// then the local repositories discovered by the scan.
let total = announcements.len() + local_repos.len();