refactor state init

This commit is contained in:
2026-09-18 20:22:51 +07:00
parent 1b6ef6f574
commit 91c40b0799
9 changed files with 158 additions and 140 deletions
+29 -32
View File
@@ -31,6 +31,12 @@ fn main() {
.with_assets(Assets)
.with_http_client(Arc::new(reqwest_client::ReqwestClient::new()))
.run(move |cx| {
// Initialize components
ui::init(cx);
// Initialize theme registry
theme::init(cx);
// Load embedded fonts in assets/fonts
load_embedded_fonts(cx);
@@ -55,6 +61,29 @@ fn main() {
disabled: false,
}]);
// Initialize settings
settings::init(cx);
// Initialize the nostr client
state::init(cx, cli_key);
// Initialize person registry
person::init(cx);
// Initialize device signer
//
// NIP-4e: https://github.com/nostr-protocol/nips/blob/per-device-keys/4e.md
device::init(cx);
// Initialize app registry
chat::init(cx);
// Initialize community registry
community::init(cx);
// Initialize auto update
auto_update::init(cx);
// Set up the window bounds
let bounds = Bounds::centered(None, size(px(960.0), px(720.0)), cx);
@@ -77,43 +106,11 @@ fn main() {
..Default::default()
};
// Open a window with default options
cx.open_window(opts, |window, cx| {
// Initialize components
ui::init(cx);
// Initialize theme registry
theme::init(cx);
// Initialize settings
settings::init(window, cx);
// Initialize the nostr client
state::init(window, cx, cli_key);
// Initialize person registry
person::init(window, cx);
// Initialize device signer
//
// NIP-4e: https://github.com/nostr-protocol/nips/blob/per-device-keys/4e.md
device::init(window, cx);
// Initialize app registry
chat::init(window, cx);
// Initialize community registry
community::init(window, cx);
// Initialize auto update
auto_update::init(window, cx);
// Root view
cx.new(|cx| Root::new(workspace::init(window, cx).into(), window, cx))
})
.expect("Failed to open window. Please restart the application.");
// Bring the app to the foreground
cx.activate(true);
});
}