ui: add support damus ui in WalletView
This appears after you've connected your wallet
This commit is contained in:
@@ -48,5 +48,5 @@ struct DamusState {
|
||||
}
|
||||
|
||||
static var empty: DamusState {
|
||||
return DamusState.init(pool: RelayPool(), keypair: Keypair(pubkey: "", privkey: ""), likes: EventCounter(our_pubkey: ""), boosts: EventCounter(our_pubkey: ""), contacts: Contacts(our_pubkey: ""), profiles: Profiles(), dms: DirectMessagesModel(our_pubkey: ""), previews: PreviewCache(), zaps: Zaps(our_pubkey: ""), lnurls: LNUrls(), settings: UserSettingsStore(), relay_filters: RelayFilters(our_pubkey: ""), relay_metadata: RelayMetadatas(), drafts: Drafts(), events: EventCache(), bookmarks: BookmarksManager(pubkey: ""), postbox: PostBox(pool: RelayPool()), bootstrap_relays: [], replies: ReplyCounter(our_pubkey: ""), muted_threads: MutedThreadsManager(keypair: Keypair(pubkey: "", privkey: nil)), wallet: WalletModel()) }
|
||||
return DamusState.init(pool: RelayPool(), keypair: Keypair(pubkey: "", privkey: ""), likes: EventCounter(our_pubkey: ""), boosts: EventCounter(our_pubkey: ""), contacts: Contacts(our_pubkey: ""), profiles: Profiles(), dms: DirectMessagesModel(our_pubkey: ""), previews: PreviewCache(), zaps: Zaps(our_pubkey: ""), lnurls: LNUrls(), settings: UserSettingsStore(), relay_filters: RelayFilters(our_pubkey: ""), relay_metadata: RelayMetadatas(), drafts: Drafts(), events: EventCache(), bookmarks: BookmarksManager(pubkey: ""), postbox: PostBox(pool: RelayPool()), bootstrap_relays: [], replies: ReplyCounter(our_pubkey: ""), muted_threads: MutedThreadsManager(keypair: Keypair(pubkey: "", privkey: nil)), wallet: WalletModel(settings: UserSettingsStore())) }
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ func format_msats_abbrev(_ msats: Int64) -> String {
|
||||
formatter.positiveSuffix = "m"
|
||||
formatter.positivePrefix = ""
|
||||
formatter.minimumFractionDigits = 0
|
||||
formatter.maximumFractionDigits = 3
|
||||
formatter.maximumFractionDigits = 2
|
||||
formatter.roundingMode = .down
|
||||
formatter.roundingIncrement = 0.1
|
||||
formatter.multiplier = 1
|
||||
|
||||
@@ -14,14 +14,15 @@ enum WalletConnectState {
|
||||
}
|
||||
|
||||
class WalletModel: ObservableObject {
|
||||
let settings: UserSettingsStore?
|
||||
var settings: UserSettingsStore
|
||||
private(set) var previous_state: WalletConnectState
|
||||
|
||||
@Published private(set) var connect_state: WalletConnectState
|
||||
|
||||
init() {
|
||||
self.connect_state = .none
|
||||
init(state: WalletConnectState, settings: UserSettingsStore) {
|
||||
self.connect_state = state
|
||||
self.previous_state = .none
|
||||
self.settings = nil
|
||||
self.settings = settings
|
||||
}
|
||||
|
||||
init(settings: UserSettingsStore) {
|
||||
@@ -42,7 +43,7 @@ class WalletModel: ObservableObject {
|
||||
}
|
||||
|
||||
func disconnect() {
|
||||
self.settings?.nostr_wallet_connect = nil
|
||||
self.settings.nostr_wallet_connect = nil
|
||||
self.connect_state = .none
|
||||
self.previous_state = .none
|
||||
}
|
||||
@@ -52,7 +53,7 @@ class WalletModel: ObservableObject {
|
||||
}
|
||||
|
||||
func connect(_ nwc: WalletConnectURL) {
|
||||
self.settings?.nostr_wallet_connect = nwc.to_url().absoluteString
|
||||
self.settings.nostr_wallet_connect = nwc.to_url().absoluteString
|
||||
notify(.attached_wallet, nwc)
|
||||
self.connect_state = .existing(nwc)
|
||||
self.previous_state = .existing(nwc)
|
||||
|
||||
Reference in New Issue
Block a user