feat: add relay group creation (#62)
Reviewed-on: #62
This commit was merged in pull request #62.
This commit is contained in:
@@ -51,6 +51,14 @@ pub struct HideGroupMeta {
|
||||
pub group: String,
|
||||
}
|
||||
|
||||
/// Ask the shell to open the channel creation dialog under a group.
|
||||
#[derive(Action, Clone, PartialEq, Eq, Deserialize)]
|
||||
#[action(namespace = nip29_ui, no_json)]
|
||||
pub struct CreateChannel {
|
||||
pub relay: RelayUrl,
|
||||
pub parent: String,
|
||||
}
|
||||
|
||||
const ADMIN_ROLE: &str = "admin";
|
||||
const LOAD_OLDER_THRESHOLD: usize = 20;
|
||||
|
||||
@@ -96,6 +104,7 @@ pub fn actions(group: WeakEntity<Group>, cx: &App) -> AnyElement {
|
||||
let info = group.clone();
|
||||
let edit = group.clone();
|
||||
let invite = group.clone();
|
||||
let channel = group.clone();
|
||||
let leave = group;
|
||||
|
||||
h_flex()
|
||||
@@ -131,6 +140,27 @@ pub fn actions(group: WeakEntity<Group>, cx: &App) -> AnyElement {
|
||||
invite::open(invite.clone(), window, cx);
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
Button::new("group-channel")
|
||||
.icon(IconName::Plus)
|
||||
.tooltip("Create channel")
|
||||
.ghost()
|
||||
.small()
|
||||
.on_click(move |_, window, cx| {
|
||||
let Ok(key) = channel.read_with(cx, |group, _cx| group.key().clone())
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
window.dispatch_action(
|
||||
Box::new(CreateChannel {
|
||||
relay: key.relay().clone(),
|
||||
parent: key.id().as_str().to_owned(),
|
||||
}),
|
||||
cx,
|
||||
);
|
||||
}),
|
||||
)
|
||||
})
|
||||
.child(
|
||||
Button::new("leave")
|
||||
@@ -927,7 +957,12 @@ impl Panel for GroupPanel {
|
||||
.child(display_name(group))
|
||||
.into_any_element()
|
||||
})
|
||||
.unwrap_or_else(|| div().text_style(TextStyle::Caption).child("Unknown").into_any_element())
|
||||
.unwrap_or_else(|| {
|
||||
div()
|
||||
.text_style(TextStyle::Caption)
|
||||
.child("Unknown")
|
||||
.into_any_element()
|
||||
})
|
||||
}
|
||||
|
||||
fn toolbar_buttons(&self, _window: &Window, _cx: &App) -> Vec<Button> {
|
||||
|
||||
@@ -77,28 +77,28 @@ pub(crate) fn open(group: WeakEntity<Group>, window: &mut Window, cx: &mut App)
|
||||
.child(
|
||||
Switch::new("private")
|
||||
.label("Private")
|
||||
.description("Only members can read messages.")
|
||||
.description("Only members can read group messages")
|
||||
.checked(current.private)
|
||||
.on_click(toggle(&flags, |flags| &mut flags.private)),
|
||||
)
|
||||
.child(
|
||||
Switch::new("restricted")
|
||||
.label("Restricted")
|
||||
.description("Only members can send messages.")
|
||||
.description("Only members can post messages")
|
||||
.checked(current.restricted)
|
||||
.on_click(toggle(&flags, |flags| &mut flags.restricted)),
|
||||
)
|
||||
.child(
|
||||
Switch::new("hidden")
|
||||
.label("Hidden")
|
||||
.description("Hide the group from non-members.")
|
||||
.description("Hidden from non-members, not discoverable")
|
||||
.checked(current.hidden)
|
||||
.on_click(toggle(&flags, |flags| &mut flags.hidden)),
|
||||
)
|
||||
.child(
|
||||
Switch::new("closed")
|
||||
.label("Closed")
|
||||
.description("Ignore join requests.")
|
||||
.description("Join requests are ignored (invite-only)")
|
||||
.checked(current.closed)
|
||||
.on_click(toggle(&flags, |flags| &mut flags.closed)),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user