clean up and add community invite
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
use community::CommunityRegistry;
|
||||
use gpui::{App, AppContext, ParentElement, Styled, Window, px};
|
||||
use ui::WindowExtension;
|
||||
use ui::input::{Input, InputState};
|
||||
|
||||
pub fn open(window: &mut Window, cx: &mut App) {
|
||||
let link_input = cx.new(|cx| InputState::new(window, cx).placeholder("Invite link"));
|
||||
|
||||
window.open_dialog(cx, move |this, _window, _cx| {
|
||||
let link_input = link_input.clone();
|
||||
|
||||
this.width(px(420.))
|
||||
.confirm()
|
||||
.title("Join community")
|
||||
.child(Input::new(&link_input).text_sm())
|
||||
.on_ok(move |_event, _window, cx| {
|
||||
let community = CommunityRegistry::global(cx);
|
||||
let link = link_input.read(cx).value().trim().to_owned();
|
||||
|
||||
if link.is_empty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
community.update(cx, |this, cx| {
|
||||
this.join(link, cx);
|
||||
});
|
||||
|
||||
true
|
||||
})
|
||||
});
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
pub mod import;
|
||||
pub mod join_community;
|
||||
pub mod new_chat;
|
||||
pub mod new_community;
|
||||
pub mod restore;
|
||||
|
||||
@@ -21,7 +21,7 @@ use ui::notification::{Notification, NotificationKind};
|
||||
use ui::{IconName, Root, Sizable, WindowExtension, h_flex, v_flex};
|
||||
|
||||
use crate::dialogs::restore::RestoreEncryption;
|
||||
use crate::dialogs::{new_chat, new_community, settings};
|
||||
use crate::dialogs::{join_community, new_chat, new_community, settings};
|
||||
use crate::panels::{
|
||||
backup, browse, contact_list, greeter, inbox, messaging_relays, profile, relay_list, requests,
|
||||
search,
|
||||
@@ -61,6 +61,7 @@ enum Command {
|
||||
ShowSearch,
|
||||
NewChat,
|
||||
NewCommunity,
|
||||
JoinCommunity,
|
||||
}
|
||||
|
||||
pub struct Workspace {
|
||||
@@ -294,6 +295,9 @@ impl Workspace {
|
||||
Command::NewCommunity => {
|
||||
new_community::open(window, cx);
|
||||
}
|
||||
Command::JoinCommunity => {
|
||||
join_community::open(window, cx);
|
||||
}
|
||||
Command::ShowBackup => {
|
||||
self.add_panel_to_dock(backup::init(window, cx), DockPlacement::Left, window, cx);
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ impl Sidebar {
|
||||
.gap_1()
|
||||
.child(
|
||||
NavItem::new(
|
||||
"new-community",
|
||||
"new",
|
||||
"New Community",
|
||||
Icon::new(IconName::Group).small(),
|
||||
)
|
||||
@@ -594,6 +594,16 @@ impl Sidebar {
|
||||
window.dispatch_action(Box::new(Command::NewCommunity), cx)
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
NavItem::new(
|
||||
"join",
|
||||
"Join Community",
|
||||
Icon::new(IconName::Invite).small(),
|
||||
)
|
||||
.on_click(|_, window, cx| {
|
||||
window.dispatch_action(Box::new(Command::JoinCommunity), cx)
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
NavItem::new("browse", "Browse", Icon::new(IconName::Compass).small())
|
||||
.on_click(|_, window, cx| {
|
||||
|
||||
Reference in New Issue
Block a user