nip19: generate nip19 data in ellipsis & share menus
In the ellipsis menu, when the user selects the 'Copy user public key', an nprofile Bech32 entity will be generated which will include TLV data with the user's public key and entire relay list, if available. The nprofile will be added to the user's copy clipboard. When the user presses the share menu on an event and clicks the 'copy link' button, a damus link with the nevent for the note will be generated and copied to the user's clipboard. Closes: https://github.com/damus-io/damus/issues/1844 Changelog-Changed: Generate nprofile/nevent links in share menus Lightning-url: LNURL1DP68GURN8GHJ7EM9W3SKCCNE9E3K7MF0D3H82UNVWQHKWUN9V4HXGCTHDC6RZVGR8SW3G Signed-off-by: kernelkind <kernelkind@gmail.com> Reviewed-by: William Casarin <jb55@jb55.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
William Casarin
parent
0650a62791
commit
5840b85213
@@ -20,6 +20,7 @@ class ProfileModel: ObservableObject, Equatable {
|
||||
var seen_event: Set<NoteId> = Set()
|
||||
var sub_id = UUID().description
|
||||
var prof_subid = UUID().description
|
||||
var findRelay_subid = UUID().description
|
||||
|
||||
init(pubkey: Pubkey, damus: DamusState) {
|
||||
self.pubkey = pubkey
|
||||
@@ -139,6 +140,27 @@ class ProfileModel: ObservableObject, Equatable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func findRelaysHandler(relay_id: String, ev: NostrConnectionEvent) {
|
||||
if case .nostr_event(let resp) = ev, case .event(_, let event) = resp, case .contacts = event.known_kind {
|
||||
self.relays = decode_json_relays(event.content)
|
||||
}
|
||||
}
|
||||
|
||||
func subscribeToFindRelays() {
|
||||
var profile_filter = NostrFilter(kinds: [.contacts])
|
||||
profile_filter.authors = [pubkey]
|
||||
|
||||
damus.pool.subscribe(sub_id: findRelay_subid, filters: [profile_filter], handler: findRelaysHandler)
|
||||
}
|
||||
|
||||
func unsubscribeFindRelays() {
|
||||
damus.pool.unsubscribe(sub_id: findRelay_subid)
|
||||
}
|
||||
|
||||
func getRelayStrings() -> [String] {
|
||||
return relays?.keys.map {$0} ?? []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user