chore: restructure
This commit is contained in:
@@ -14,19 +14,12 @@ struct GlobalAccount(Entity<Account>);
|
||||
impl Global for GlobalAccount {}
|
||||
|
||||
pub fn init(cx: &mut App) {
|
||||
Account::set_global(
|
||||
cx.new(|_| Account {
|
||||
profile: None,
|
||||
loading: false,
|
||||
}),
|
||||
cx,
|
||||
);
|
||||
Account::set_global(cx.new(|_| Account { profile: None }), cx);
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Account {
|
||||
pub profile: Option<Profile>,
|
||||
loading: bool,
|
||||
}
|
||||
|
||||
impl Account {
|
||||
@@ -42,12 +35,6 @@ impl Account {
|
||||
where
|
||||
S: NostrSigner + 'static,
|
||||
{
|
||||
if self.loading {
|
||||
return;
|
||||
}
|
||||
|
||||
self.set_loading(true, cx);
|
||||
|
||||
let task: Task<Result<Profile, Error>> = cx.background_spawn(async move {
|
||||
let client = get_client();
|
||||
// Use user's signer for main signer
|
||||
@@ -72,7 +59,6 @@ impl Account {
|
||||
cx.update(|_, cx| {
|
||||
this.update(cx, |this, cx| {
|
||||
this.profile = Some(profile);
|
||||
this.set_loading(false, cx);
|
||||
this.subscribe(cx);
|
||||
cx.notify();
|
||||
})
|
||||
@@ -178,9 +164,4 @@ impl Account {
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
|
||||
fn set_loading(&mut self, loading: bool, cx: &mut Context<Self>) {
|
||||
self.loading = loading;
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ reqwest_client.workspace = true
|
||||
|
||||
nostr-connect.workspace = true
|
||||
nostr-sdk.workspace = true
|
||||
|
||||
anyhow.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
BIN
crates/coop/resources/128x128.png
Normal file
BIN
crates/coop/resources/128x128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.4 KiB |
BIN
crates/coop/resources/128x128@2x.png
Normal file
BIN
crates/coop/resources/128x128@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
crates/coop/resources/32x32.png
Normal file
BIN
crates/coop/resources/32x32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
crates/coop/resources/app-icon.icns
Normal file
BIN
crates/coop/resources/app-icon.icns
Normal file
Binary file not shown.
BIN
crates/coop/resources/app-icon.ico
Normal file
BIN
crates/coop/resources/app-icon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
BIN
crates/coop/resources/app-icon.png
Normal file
BIN
crates/coop/resources/app-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
@@ -157,6 +157,10 @@ impl Login {
|
||||
}
|
||||
|
||||
fn login(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.is_logging_in {
|
||||
return;
|
||||
};
|
||||
|
||||
self.set_logging_in(true, cx);
|
||||
|
||||
let content = self.key_input.read(cx).text();
|
||||
Reference in New Issue
Block a user