nip19: fix shared nevents that are too long
There comes a point when the sharing a Nip19 mention becomes unwieldy when there is too much TLV data. This patch features a naive approach to making sure the relay portion of the TLV data doesn't contribute too much data to the mention. It adds a maximum number of relays that should be shared in the mention, right now it is set to four. Changelog-Fixed: Fix shared nevents that are too long Lightning-address: kernelkind@getalby.com 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
5c76ffda8c
commit
7cc2825d89
@@ -13,6 +13,8 @@ class ProfileModel: ObservableObject, Equatable {
|
||||
@Published var relays: [String: RelayInfo]? = nil
|
||||
@Published var progress: Int = 0
|
||||
|
||||
private let MAX_SHARE_RELAYS = 4
|
||||
|
||||
var events: EventHolder
|
||||
let pubkey: Pubkey
|
||||
let damus: DamusState
|
||||
@@ -161,6 +163,10 @@ class ProfileModel: ObservableObject, Equatable {
|
||||
func getRelayStrings() -> [String] {
|
||||
return relays?.keys.map {$0} ?? []
|
||||
}
|
||||
|
||||
func getCappedRelayStrings() -> [String] {
|
||||
return relays?.keys.prefix(MAX_SHARE_RELAYS).map { $0 } ?? []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user