chore: rework login and identity (#129)
* . * redesign onboarding screen * . * add signer proxy * . * . * . * . * fix proxy * clean up * fix new account
This commit is contained in:
@@ -4,7 +4,7 @@ pub const APP_PUBKEY: &str = "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZX
|
||||
pub const APP_UPDATER_ENDPOINT: &str = "https://coop-updater.reya.su/";
|
||||
pub const KEYRING_URL: &str = "Coop Safe Storage";
|
||||
|
||||
pub const ACCOUNT_D: &str = "coop:account";
|
||||
pub const ACCOUNT_IDENTIFIER: &str = "coop:user";
|
||||
pub const SETTINGS_D: &str = "coop:settings";
|
||||
|
||||
/// Bootstrap Relays.
|
||||
|
||||
@@ -5,6 +5,7 @@ use std::time::Duration;
|
||||
use nostr_connect::prelude::*;
|
||||
use nostr_sdk::prelude::*;
|
||||
use paths::nostr_file;
|
||||
use smol::channel::{Receiver, Sender};
|
||||
use smol::lock::RwLock;
|
||||
|
||||
use crate::paths::support_dir;
|
||||
@@ -13,8 +14,17 @@ pub mod constants;
|
||||
pub mod paths;
|
||||
|
||||
/// Signals sent through the global event channel to notify UI components
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug)]
|
||||
pub enum NostrSignal {
|
||||
/// Signer has been set
|
||||
SignerSet(PublicKey),
|
||||
|
||||
/// Signer has been unset
|
||||
SignerUnset,
|
||||
|
||||
/// Browser Signer Proxy service is not running
|
||||
ProxyDown,
|
||||
|
||||
/// Received a new metadata event from Relay Pool
|
||||
Metadata(Event),
|
||||
|
||||
@@ -35,6 +45,7 @@ pub enum NostrSignal {
|
||||
}
|
||||
|
||||
static NOSTR_CLIENT: OnceLock<Client> = OnceLock::new();
|
||||
static GLOBAL_CHANNEL: OnceLock<(Sender<NostrSignal>, Receiver<NostrSignal>)> = OnceLock::new();
|
||||
static PROCESSED_EVENTS: OnceLock<RwLock<BTreeSet<EventId>>> = OnceLock::new();
|
||||
static CURRENT_TIMESTAMP: OnceLock<Timestamp> = OnceLock::new();
|
||||
static FIRST_RUN: OnceLock<bool> = OnceLock::new();
|
||||
@@ -63,6 +74,13 @@ pub fn nostr_client() -> &'static Client {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn global_channel() -> &'static (Sender<NostrSignal>, Receiver<NostrSignal>) {
|
||||
GLOBAL_CHANNEL.get_or_init(|| {
|
||||
let (sender, receiver) = smol::channel::bounded::<NostrSignal>(2048);
|
||||
(sender, receiver)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn processed_events() -> &'static RwLock<BTreeSet<EventId>> {
|
||||
PROCESSED_EVENTS.get_or_init(|| RwLock::new(BTreeSet::new()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user