feat: redesign the sidebar and workspace (#53)
Reviewed-on: #53
This commit was merged in pull request #53.
This commit is contained in:
@@ -11,7 +11,7 @@ use concord::cord06::RekeyScope;
|
||||
use concord::derive::{channel_group_key, grant_locator};
|
||||
use concord::state::{ChannelCursor, ChannelKeyRef, CommunityState, HeldKey, HeldRoot};
|
||||
use concord::{ChannelId, CommunityId, Epoch};
|
||||
use gpui::{App, AppContext, Context, EventEmitter, Task};
|
||||
use gpui::{App, AppContext, Context, EventEmitter, SharedString, Task};
|
||||
use nostr_sdk::prelude::*;
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use state::NostrRegistry;
|
||||
@@ -107,8 +107,6 @@ impl SubscriptionKey {
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum CommunityEvent {
|
||||
Updated(CommunityId),
|
||||
Open(CommunityId),
|
||||
Close(CommunityId),
|
||||
Channel(CommunityId, ChannelId),
|
||||
/// History exists here that no held key can open.
|
||||
Unreadable(CommunityId),
|
||||
@@ -180,15 +178,16 @@ impl Community {
|
||||
&self.state
|
||||
}
|
||||
|
||||
pub fn name(&self) -> String {
|
||||
pub fn name(&self) -> SharedString {
|
||||
if let Some(metadata) = &self.control.community {
|
||||
return metadata.name.clone();
|
||||
return SharedString::from(&metadata.name);
|
||||
}
|
||||
|
||||
self.state
|
||||
.name
|
||||
.clone()
|
||||
.unwrap_or_else(|| self.state.id.to_hex())
|
||||
.as_ref()
|
||||
.map(SharedString::from)
|
||||
.unwrap_or_else(|| SharedString::from("Unknown"))
|
||||
}
|
||||
|
||||
pub fn control(&self) -> &ControlFold {
|
||||
|
||||
@@ -7,7 +7,7 @@ pub use concord::cord03::{ChatMessage, ReplyRef};
|
||||
use concord::state::CommunityState;
|
||||
pub use concord::{ChannelId, CommunityId, Epoch};
|
||||
use futures::future::{Either, select};
|
||||
use gpui::{App, AppContext, Context, Entity, EventEmitter, Global, Subscription, Task, Window};
|
||||
use gpui::{App, AppContext, Context, Entity, EventEmitter, Global, Subscription, Task};
|
||||
use nostr_sdk::prelude::*;
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use state::NostrRegistry;
|
||||
@@ -225,27 +225,6 @@ impl CommunityRegistry {
|
||||
self.index.get(id).cloned()
|
||||
}
|
||||
|
||||
/// Ask the workspace to open a community's panel.
|
||||
pub fn emit_community(
|
||||
&mut self,
|
||||
community: &Entity<Community>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let id = community.read(cx).id();
|
||||
|
||||
cx.defer_in(window, move |_this, _window, cx| {
|
||||
cx.emit(CommunityEvent::Open(id));
|
||||
});
|
||||
}
|
||||
|
||||
/// Ask the workspace to close a community's panel.
|
||||
pub fn emit_close(&mut self, id: CommunityId, window: &mut Window, cx: &mut Context<Self>) {
|
||||
cx.defer_in(window, move |_this, _window, cx| {
|
||||
cx.emit(CommunityEvent::Close(id));
|
||||
});
|
||||
}
|
||||
|
||||
/// Create a community owned by the current account and begin tracking it.
|
||||
pub fn create(&mut self, metadata: CommunityMetadata, cx: &mut Context<Self>) {
|
||||
let nostr = NostrRegistry::global(cx);
|
||||
|
||||
Reference in New Issue
Block a user