From 0d2ab6aff39ef53e4888d77d19f13b6ebd00c0e5 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Mon, 2 Jan 2023 12:41:28 -0800 Subject: [PATCH] NostrResponse: add sub_id helper Handy to guard on this --- damus/Nostr/NostrResponse.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/damus/Nostr/NostrResponse.swift b/damus/Nostr/NostrResponse.swift index 7b37e18..2f15679 100644 --- a/damus/Nostr/NostrResponse.swift +++ b/damus/Nostr/NostrResponse.swift @@ -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()