NostrResponse: add sub_id helper

Handy to guard on this
This commit is contained in:
William Casarin
2023-01-02 12:41:28 -08:00
parent e3732b3adc
commit 0d2ab6aff3

View File

@@ -11,6 +11,17 @@ enum NostrResponse: Decodable {
case event(String, NostrEvent)
case notice(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 {
var container = try decoder.unkeyedContainer()