update
This commit is contained in:
@@ -10,8 +10,9 @@ use dock::{
|
||||
};
|
||||
use gpui::prelude::*;
|
||||
use gpui::{
|
||||
AnyElement, App, Context, Div, EventEmitter, FocusHandle, Focusable, Hsla, ObjectFit, Render,
|
||||
SharedString, Subscription, WeakEntity, Window, div, img, px, relative, uniform_list, white,
|
||||
AnyElement, App, Context, Div, Entity, EventEmitter, FocusHandle, Focusable, Hsla, ObjectFit,
|
||||
Render, SharedString, Subscription, WeakEntity, Window, div, img, px, relative, uniform_list,
|
||||
white,
|
||||
};
|
||||
use gpui_base::Button as BaseButton;
|
||||
use gpui_component::button::{Button, ButtonVariants};
|
||||
@@ -264,31 +265,71 @@ impl SidebarPanel {
|
||||
}
|
||||
|
||||
/// The detail view offers to publish it to NIP-34.
|
||||
fn open_local_repo(&mut self, path: PathBuf, window: &mut Window, cx: &mut Context<Self>) {
|
||||
fn open_local_repo(
|
||||
&mut self,
|
||||
path: PathBuf,
|
||||
nip34: Option<Nip34Binding>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let detail =
|
||||
cx.new(|cx| RepoDetailView::new_local(self.dock_area.clone(), path, window, cx));
|
||||
|
||||
self.dock_area
|
||||
.update(cx, |dock_area, cx| {
|
||||
add_center_panel(dock_area, panel_handle(detail), window, cx);
|
||||
})
|
||||
.ok();
|
||||
cx.new(|cx| RepoDetailView::new_local(self.dock_area.clone(), path, nip34, window, cx));
|
||||
self.add_detail_panel(detail, window, cx);
|
||||
}
|
||||
|
||||
/// A local repository opens as the announced repository when its binding matches one,
|
||||
/// and as a local-only repository otherwise.
|
||||
/// A local repository whose binding matches an announcement opens as the announced repository.
|
||||
fn open_local_announced(
|
||||
&mut self,
|
||||
announcement: Announcement,
|
||||
path: PathBuf,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let detail = cx.new(|cx| {
|
||||
RepoDetailView::new_local_announced(
|
||||
self.dock_area.clone(),
|
||||
announcement,
|
||||
path,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
});
|
||||
self.add_detail_panel(detail, window, cx);
|
||||
}
|
||||
|
||||
/// A local repository opens as the announced repository
|
||||
/// when its binding matches one, and as a local-only repository otherwise.
|
||||
fn open_local_entry(
|
||||
&mut self,
|
||||
entry: ResolvedLocalRepo,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let Some(announcement) = entry.announcement {
|
||||
self.open_repo(&announcement, window, cx);
|
||||
let ResolvedLocalRepo {
|
||||
path,
|
||||
nip34,
|
||||
announcement,
|
||||
} = entry;
|
||||
|
||||
if let Some(announcement) = announcement {
|
||||
self.open_local_announced(announcement, path, window, cx);
|
||||
return;
|
||||
}
|
||||
|
||||
self.open_local_repo(entry.path, window, cx);
|
||||
self.open_local_repo(path, nip34, window, cx);
|
||||
}
|
||||
|
||||
fn add_detail_panel(
|
||||
&mut self,
|
||||
detail: Entity<RepoDetailView>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.dock_area
|
||||
.update(cx, |dock_area, cx| {
|
||||
add_center_panel(dock_area, panel_handle(detail), window, cx);
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
|
||||
fn render_repos(&self, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
|
||||
Reference in New Issue
Block a user