chore: improve render modal and update deps

This commit is contained in:
2025-07-17 07:54:40 +07:00
parent 73a2678278
commit 59cfdb9ae2
5 changed files with 64 additions and 57 deletions

View File

@@ -160,11 +160,6 @@ impl ChatSpace {
if !state.read(cx).has_signer() {
this.open_onboarding(window, cx);
} else {
// Load all chat rooms from database
Registry::global(cx).update(cx, |this, cx| {
this.load_rooms(window, cx);
});
// Open chat panels
this.open_chats(window, cx);
}
},
@@ -229,6 +224,11 @@ impl ChatSpace {
// Enable the toolbar for logged in users
self.toolbar(true, cx);
// Load all chat rooms from database
Registry::global(cx).update(cx, |this, cx| {
this.load_rooms(window, cx);
});
let weak_dock = self.dock.downgrade();
let left = DockItem::panel(Arc::new(sidebar::init(window, cx)));
let center = DockItem::split_with_sizes(

View File

@@ -103,6 +103,8 @@ impl Compose {
.map(|profile| Contact::new(profile.public_key()))
.collect_vec();
log::info!("get contacts");
Ok(contacts)
});

View File

@@ -51,11 +51,11 @@ impl Preferences {
fn open_edit_profile(&self, window: &mut Window, cx: &mut Context<Self>) {
let edit_profile = edit_profile::init(window, cx);
let title = SharedString::new(t!("preferences.modal_profile_title"));
window.open_modal(cx, move |modal, _window, _cx| {
let title = SharedString::new(t!("preferences.modal_profile_title"));
modal
.title(title)
.title(title.clone())
.width(px(DEFAULT_MODAL_WIDTH))
.child(edit_profile.clone())
});
@@ -63,11 +63,11 @@ impl Preferences {
fn open_relays(&self, window: &mut Window, cx: &mut Context<Self>) {
let relays = relays::init(window, cx);
let title = SharedString::new(t!("preferences.modal_relays_title"));
window.open_modal(cx, move |this, _window, _cx| {
let title = SharedString::new(t!("preferences.modal_relays_title"));
this.width(px(DEFAULT_MODAL_WIDTH))
.title(title)
.title(title.clone())
.child(relays.clone())
});
}

View File

@@ -576,41 +576,46 @@ impl Sidebar {
fn open_compose(&self, window: &mut Window, cx: &mut Context<Self>) {
let compose = compose::init(window, cx);
let title = SharedString::new(t!("sidebar.direct_messages"));
window.open_modal(cx, move |modal, _window, _cx| {
modal
.title(SharedString::new(t!("sidebar.direct_messages")))
.title(title.clone())
.width(px(DEFAULT_MODAL_WIDTH))
.child(compose.clone())
});
}
fn open_loading_modal(&self, window: &mut Window, cx: &mut Context<Self>) {
let title = SharedString::new(t!("sidebar.loading_modal_title"));
let text_1 = SharedString::new(t!("sidebar.loading_modal_body_1"));
let text_2 = SharedString::new(t!("sidebar.loading_modal_body_2"));
let desc = SharedString::new(t!("sidebar.loading_modal_description"));
window.open_modal(cx, move |this, _window, cx| {
this.title(SharedString::new(t!("sidebar.loading_modal_title")))
.child(
div()
.px_4()
.pb_4()
.flex()
.flex_col()
.gap_2()
.child(
div()
.flex()
.flex_col()
.gap_2()
.text_sm()
.child(SharedString::new(t!("sidebar.loading_modal_body_1")))
.child(SharedString::new(t!("sidebar.loading_modal_body_2"))),
)
.child(
div()
.text_xs()
.text_color(cx.theme().text_muted)
.child(SharedString::new(t!("sidebar.loading_modal_description"))),
),
)
this.title(title.clone()).child(
div()
.px_4()
.pb_4()
.flex()
.flex_col()
.gap_2()
.child(
div()
.flex()
.flex_col()
.gap_2()
.text_sm()
.child(text_1.clone())
.child(text_2.clone()),
)
.child(
div()
.text_xs()
.text_color(cx.theme().text_muted)
.child(desc.clone()),
),
)
});
}