Update nostr-sdk and adapt to new EventBuilder API
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run
Rust / build (macos-latest, stable) (push) Waiting to run
Rust / build (ubuntu-latest, stable) (push) Waiting to run
Rust / build (windows-latest, stable) (push) Waiting to run
Rust / build (macos-latest, stable) (pull_request) Waiting to run
Rust / build (ubuntu-latest, stable) (pull_request) Waiting to run
Rust / build (windows-latest, stable) (pull_request) Waiting to run
This commit is contained in:
@@ -36,7 +36,7 @@ pub struct AppRoot {
|
||||
impl AppRoot {
|
||||
pub fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||
let workspace = cx.new(|_| Workspace::new());
|
||||
let titlebar = cx.new(|cx| TitlebarView::new(workspace.downgrade(), cx));
|
||||
let titlebar = cx.new(|cx| TitlebarView::new(workspace.downgrade(), window, cx));
|
||||
let toasts = cx.new(|_| Toasts::default());
|
||||
let sign_in = cx.new(|_| SignedOutView::new());
|
||||
let empty = cx.new(|_| PlaceholderView::new("Select a repository"));
|
||||
@@ -94,14 +94,14 @@ impl Render for AppRoot {
|
||||
let titlebar_view = self.titlebar.read(cx);
|
||||
|
||||
let mut titlebar = Titlebar::new("signed-titlebar");
|
||||
if let Some(menu) = titlebar_view.render_user_menu(cx) {
|
||||
titlebar = titlebar.child(menu);
|
||||
if let Some(actions) = titlebar_view.render_actions(cx) {
|
||||
titlebar = titlebar.child(actions);
|
||||
}
|
||||
if let Some(tabs) = titlebar_view.render_tabs(cx) {
|
||||
titlebar = titlebar.tab_bar(tabs);
|
||||
}
|
||||
if let Some(actions) = titlebar_view.render_actions(cx) {
|
||||
titlebar = titlebar.suffix(actions);
|
||||
if let Some(menu) = titlebar_view.render_user_menu(cx) {
|
||||
titlebar = titlebar.suffix(menu);
|
||||
}
|
||||
|
||||
let workspace = self.workspace.read(cx);
|
||||
@@ -118,7 +118,7 @@ impl Render for AppRoot {
|
||||
row = row.main(self.sign_in.clone());
|
||||
}
|
||||
|
||||
div()
|
||||
let mut root = div()
|
||||
.relative()
|
||||
.size_full()
|
||||
.font_family(".SystemUIFont")
|
||||
@@ -130,6 +130,10 @@ impl Render for AppRoot {
|
||||
.transparent(true)
|
||||
.toasts(self.toasts.clone()),
|
||||
)
|
||||
.child(self.dialogs.clone())
|
||||
.child(self.dialogs.clone());
|
||||
if is_signed_in {
|
||||
root = root.child(titlebar_view.palette());
|
||||
}
|
||||
root
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ impl RepoDetailView {
|
||||
.child(
|
||||
div()
|
||||
.min_w_0()
|
||||
.typeset(TextRole::Body, cx)
|
||||
.typeset(TextRole::Callout, cx)
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.line_clamp(3)
|
||||
.child(description),
|
||||
@@ -180,79 +180,6 @@ impl RepoDetailView {
|
||||
.flex_none()
|
||||
.gap_2()
|
||||
.justify_end()
|
||||
.child(
|
||||
DropdownMenu::new("repo-menu")
|
||||
.variant(ButtonVariant::Secondary)
|
||||
.loading(pushing)
|
||||
.disabled(pushing)
|
||||
.open(self.repo_menu_open)
|
||||
.on_open_change(move |open, _, cx| {
|
||||
if let Err(error) = weak_menu_open.update(cx, |this, cx| {
|
||||
this.repo_menu_open = open;
|
||||
cx.notify();
|
||||
}) {
|
||||
log::warn!("failed to update repo menu: {error}");
|
||||
}
|
||||
})
|
||||
.items(move |_, cx| {
|
||||
let owner = backend.read(cx).current_user()
|
||||
== Some(announcement_for_menu.owner);
|
||||
|
||||
let mut items = vec![MenuItem::new("About").handler({
|
||||
let weak = weak_menu_items.clone();
|
||||
let announcement = announcement_for_menu.clone();
|
||||
move |_, cx| {
|
||||
if let Err(error) = weak.update(cx, |this, cx| {
|
||||
dialogs::about::open(
|
||||
announcement.clone(),
|
||||
this.directory.clone(),
|
||||
cx,
|
||||
);
|
||||
}) {
|
||||
log::warn!("failed to open about: {error}");
|
||||
}
|
||||
}
|
||||
})];
|
||||
|
||||
if owner {
|
||||
items.push(MenuItem::new("Republish").handler({
|
||||
let weak = weak_menu_items.clone();
|
||||
move |window, cx| {
|
||||
if let Err(error) = weak.update(cx, |this, cx| {
|
||||
this.push_repository(window, cx);
|
||||
}) {
|
||||
log::warn!("failed to republish: {error}");
|
||||
}
|
||||
}
|
||||
}));
|
||||
items.push(MenuItem::new("Reset remote to local").handler({
|
||||
let weak = weak_menu_items.clone();
|
||||
move |window, cx| {
|
||||
if let Err(error) = weak.update(cx, |this, cx| {
|
||||
this.reset_remote(window, cx);
|
||||
}) {
|
||||
log::warn!("failed to reset remote: {error}");
|
||||
}
|
||||
}
|
||||
}));
|
||||
items.push(MenuItem::separator());
|
||||
items.push(MenuItem::new("Delete").destructive(true).handler(
|
||||
{
|
||||
let weak = weak_menu_items.clone();
|
||||
move |window, cx| {
|
||||
if let Err(error) = weak.update(cx, |this, cx| {
|
||||
this.delete_repository(window, cx);
|
||||
}) {
|
||||
log::warn!("failed to delete: {error}");
|
||||
}
|
||||
}
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
items
|
||||
}),
|
||||
)
|
||||
.when_some(self.render_sync_button(cx), |this, button| {
|
||||
this.child(button)
|
||||
})
|
||||
@@ -341,6 +268,79 @@ impl RepoDetailView {
|
||||
)
|
||||
.into_any_element()
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
DropdownMenu::new("repo-menu")
|
||||
.icon(CustomIconName::EllipsisVertical)
|
||||
.variant(ButtonVariant::Ghost)
|
||||
.disabled(pushing)
|
||||
.open(self.repo_menu_open)
|
||||
.on_open_change(move |open, _, cx| {
|
||||
if let Err(error) = weak_menu_open.update(cx, |this, cx| {
|
||||
this.repo_menu_open = open;
|
||||
cx.notify();
|
||||
}) {
|
||||
log::warn!("failed to update repo menu: {error}");
|
||||
}
|
||||
})
|
||||
.items(move |_, cx| {
|
||||
let owner = backend.read(cx).current_user()
|
||||
== Some(announcement_for_menu.owner);
|
||||
|
||||
let mut items = vec![MenuItem::new("About").handler({
|
||||
let weak = weak_menu_items.clone();
|
||||
let announcement = announcement_for_menu.clone();
|
||||
move |_, cx| {
|
||||
if let Err(error) = weak.update(cx, |this, cx| {
|
||||
dialogs::about::open(
|
||||
announcement.clone(),
|
||||
this.directory.clone(),
|
||||
cx,
|
||||
);
|
||||
}) {
|
||||
log::warn!("failed to open about: {error}");
|
||||
}
|
||||
}
|
||||
})];
|
||||
|
||||
if owner {
|
||||
items.push(MenuItem::new("Republish").handler({
|
||||
let weak = weak_menu_items.clone();
|
||||
move |window, cx| {
|
||||
if let Err(error) = weak.update(cx, |this, cx| {
|
||||
this.push_repository(window, cx);
|
||||
}) {
|
||||
log::warn!("failed to republish: {error}");
|
||||
}
|
||||
}
|
||||
}));
|
||||
items.push(MenuItem::new("Reset remote to local").handler({
|
||||
let weak = weak_menu_items.clone();
|
||||
move |window, cx| {
|
||||
if let Err(error) = weak.update(cx, |this, cx| {
|
||||
this.reset_remote(window, cx);
|
||||
}) {
|
||||
log::warn!("failed to reset remote: {error}");
|
||||
}
|
||||
}
|
||||
}));
|
||||
items.push(MenuItem::separator());
|
||||
items.push(MenuItem::new("Delete").destructive(true).handler(
|
||||
{
|
||||
let weak = weak_menu_items.clone();
|
||||
move |window, cx| {
|
||||
if let Err(error) = weak.update(cx, |this, cx| {
|
||||
this.delete_repository(window, cx);
|
||||
}) {
|
||||
log::warn!("failed to delete: {error}");
|
||||
}
|
||||
}
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
items
|
||||
}),
|
||||
),
|
||||
)
|
||||
.into_any_element()
|
||||
@@ -365,7 +365,7 @@ impl RepoDetailView {
|
||||
v_flex()
|
||||
.flex_none()
|
||||
.p_6()
|
||||
.h_24()
|
||||
.h_32()
|
||||
.w_full()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
@@ -374,8 +374,7 @@ impl RepoDetailView {
|
||||
Some(binding) => this.child(bound_repo_label(binding, &self.directory, cx)),
|
||||
None => this.child(
|
||||
Button::new("init")
|
||||
.icon(Icon::named(CustomIconName::Init))
|
||||
.large()
|
||||
.icon(Icon::named(CustomIconName::ArrowUp))
|
||||
.label("Initialize on Nostr")
|
||||
.tooltip(Tooltip::text("Publish this repository to Nostr"))
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
@@ -456,11 +455,13 @@ impl RepoDetailView {
|
||||
_ => None,
|
||||
})
|
||||
.max_by_key(|(_, ahead)| *ahead)?;
|
||||
|
||||
let commits = if ahead == 1 {
|
||||
"1 commit".to_owned()
|
||||
} else {
|
||||
format!("{ahead} commits")
|
||||
};
|
||||
|
||||
let path = checkout.path.clone();
|
||||
(
|
||||
Icon::named(IconRole::Refresh),
|
||||
@@ -583,11 +584,12 @@ impl RepoDetailView {
|
||||
.gap_2()
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.gap_2()
|
||||
.child(
|
||||
Avatar::new(announcement.owner)
|
||||
.name(owner_name.clone())
|
||||
.picture(owner.picture()),
|
||||
.picture(owner.picture())
|
||||
.small(),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
|
||||
@@ -869,6 +869,7 @@ impl RepoDetailView {
|
||||
Sidebar::new("repo-sidebar")
|
||||
.selected(selected)
|
||||
.border_right(true)
|
||||
.transparent(false)
|
||||
.on_change(move |index, _, cx| {
|
||||
let section = match (index, include_issues) {
|
||||
(Some(0), _) => RepoSection::Commits,
|
||||
|
||||
@@ -6,6 +6,7 @@ use gpui::{
|
||||
};
|
||||
use gpui_native_kit::avatar::Avatar;
|
||||
use gpui_native_kit::button::{Button, ButtonVariant};
|
||||
use gpui_native_kit::command_palette::{Command, CommandPalette, CommandPaletteState};
|
||||
use gpui_native_kit::common::{Sizable as _, h_flex};
|
||||
use gpui_native_kit::data::tabs::{Tab, Tabs, TabsVariant};
|
||||
use gpui_native_kit::icons::{Icon, IconRole};
|
||||
@@ -28,19 +29,24 @@ mod helpers;
|
||||
pub struct TitlebarView {
|
||||
weak: WeakEntity<Self>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
scanning: bool,
|
||||
/// User's announced repositories.
|
||||
announcements: Arc<Vec<Announcement>>,
|
||||
/// Local repositories found by the scan that are not announced yet.
|
||||
local_repos: Arc<Vec<ResolvedLocalRepo>>,
|
||||
/// Profiles rendered by the titlebar tabs.
|
||||
directory: gpui::Entity<ProfileDirectory>,
|
||||
/// The command palette opened from the titlebar.
|
||||
palette: gpui::Entity<CommandPaletteState>,
|
||||
user_menu_open: bool,
|
||||
_subscriptions: Vec<Subscription>,
|
||||
}
|
||||
|
||||
impl TitlebarView {
|
||||
pub fn new(workspace: WeakEntity<Workspace>, cx: &mut Context<Self>) -> Self {
|
||||
pub fn new(
|
||||
workspace: WeakEntity<Workspace>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
let backend = Backend::global(cx);
|
||||
let repos = RepoListStore::global(cx);
|
||||
let local = LocalReposStore::global(cx);
|
||||
@@ -68,25 +74,84 @@ impl TitlebarView {
|
||||
}
|
||||
}));
|
||||
|
||||
let mut this = Self {
|
||||
weak: cx.entity().downgrade(),
|
||||
let palette = Self::new_palette(workspace.clone(), window, cx);
|
||||
|
||||
let entity = cx.entity();
|
||||
|
||||
let this = Self {
|
||||
weak: entity.downgrade(),
|
||||
workspace,
|
||||
scanning: false,
|
||||
announcements: Arc::new(Vec::new()),
|
||||
local_repos: Arc::new(Vec::new()),
|
||||
directory: ProfileDirectory::new(cx),
|
||||
palette,
|
||||
user_menu_open: false,
|
||||
_subscriptions: subscriptions,
|
||||
};
|
||||
this.refresh(cx);
|
||||
|
||||
cx.defer(move |cx| {
|
||||
entity.update(cx, |this, cx| {
|
||||
if this.refresh(cx) {
|
||||
cx.notify();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this
|
||||
}
|
||||
|
||||
fn new_palette(
|
||||
workspace: WeakEntity<Workspace>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> gpui::Entity<CommandPaletteState> {
|
||||
cx.new(|cx| {
|
||||
let matcher = |query: &str, commands: &[Command]| {
|
||||
let needle = query.to_lowercase();
|
||||
commands
|
||||
.iter()
|
||||
.filter(|command| command.label.to_lowercase().contains(&needle))
|
||||
.cloned()
|
||||
.collect()
|
||||
};
|
||||
|
||||
CommandPaletteState::new(
|
||||
CommandPalette::new("signed-command-palette", Self::palette_commands(), matcher)
|
||||
.on_execute(move |command, window, cx| match command.id.as_ref() {
|
||||
"create-repo" => dialogs::create::open(workspace.clone(), window, cx),
|
||||
"rescan-repos" => {
|
||||
let local_repos = LocalReposStore::global(cx);
|
||||
local_repos.update(cx, |store, cx| store.rescan(cx));
|
||||
}
|
||||
"open-settings" => settings::open(cx),
|
||||
"exit" => identity::helpers::open_exit(cx),
|
||||
_ => {}
|
||||
}),
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn palette_commands() -> Vec<Command> {
|
||||
vec![
|
||||
Command::new("create-repo", "Create repository").icon(Icon::named(IconRole::Plus)),
|
||||
Command::new("rescan-repos", "Rescan for local repositories")
|
||||
.icon(Icon::named(IconRole::Refresh)),
|
||||
Command::new("open-settings", "Settings").icon(Icon::named(IconRole::Settings)),
|
||||
Command::new("exit", "Exit"),
|
||||
]
|
||||
}
|
||||
|
||||
pub fn palette(&self) -> gpui::Entity<CommandPaletteState> {
|
||||
self.palette.clone()
|
||||
}
|
||||
|
||||
fn refresh(&mut self, cx: &mut Context<Self>) -> bool {
|
||||
let backend = Backend::global(cx);
|
||||
let user = backend.read(cx).current_user();
|
||||
|
||||
let (announcements, local_repos, scanning) = {
|
||||
let (announcements, local_repos) = {
|
||||
let repo_list = RepoListStore::global(cx).read(cx);
|
||||
|
||||
let announcements = user
|
||||
@@ -98,16 +163,14 @@ impl TitlebarView {
|
||||
let local_repos =
|
||||
LocalReposStore::resolve(&local.repos, &repo_list.announcements, &announcements);
|
||||
|
||||
(announcements, local_repos, local.scanning)
|
||||
(announcements, local_repos)
|
||||
};
|
||||
|
||||
let announcements_changed = *self.announcements != announcements;
|
||||
let local_changed = *self.local_repos != local_repos;
|
||||
let scanning_changed = self.scanning != scanning;
|
||||
|
||||
self.announcements = Arc::new(announcements);
|
||||
self.local_repos = Arc::new(local_repos);
|
||||
self.scanning = scanning;
|
||||
|
||||
let mut profiles: Vec<PublicKey> = user.into_iter().collect();
|
||||
let owners: Vec<PublicKey> = self
|
||||
@@ -128,7 +191,7 @@ impl TitlebarView {
|
||||
directory.track(profiles, cx);
|
||||
});
|
||||
|
||||
announcements_changed || local_changed || scanning_changed
|
||||
announcements_changed || local_changed
|
||||
}
|
||||
|
||||
pub fn render_tabs(&self, cx: &App) -> Option<Tabs> {
|
||||
@@ -348,15 +411,15 @@ impl TitlebarView {
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.child(
|
||||
Button::new("rescan-repos")
|
||||
.icon(Icon::named(IconRole::Loader))
|
||||
Button::new("open-command-palette")
|
||||
.icon(Icon::named(IconRole::Search))
|
||||
.variant(ButtonVariant::Ghost)
|
||||
.loading(self.scanning)
|
||||
.disabled(self.scanning)
|
||||
.tooltip(Tooltip::text("Rescan for local repositories"))
|
||||
.on_click(|_, _, cx| {
|
||||
let local_repos = LocalReposStore::global(cx);
|
||||
local_repos.update(cx, |store, cx| store.rescan(cx));
|
||||
.tooltip(Tooltip::text("Command palette"))
|
||||
.on_click({
|
||||
let palette = self.palette.clone();
|
||||
move |_, window, cx| {
|
||||
palette.update(cx, |palette, cx| palette.toggle(window, cx));
|
||||
}
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
|
||||
Reference in New Issue
Block a user