Browse Source

NostrResponse: add sub_id helper

Handy to guard on this
post-button-style
William Casarin 2 years ago
parent
commit
0d2ab6aff3
  1. 11
      damus/Nostr/NostrResponse.swift

11
damus/Nostr/NostrResponse.swift

@ -11,6 +11,17 @@ enum NostrResponse: Decodable {
case event(String, NostrEvent) case event(String, NostrEvent)
case notice(String) case notice(String)
case eose(String) case eose(String)
var subid: String? {
switch self {
case .event(let sub_id, _):
return sub_id
case .eose(let sub_id):
return sub_id
case .notice:
return nil
}
}
init(from decoder: Decoder) throws { init(from decoder: Decoder) throws {
var container = try decoder.unkeyedContainer() var container = try decoder.unkeyedContainer()

Loading…
Cancel
Save