From ecd8b64b8bc3dfc613eb2e81038bafaef053c6f3 Mon Sep 17 00:00:00 2001 From: Bryan Montz Date: Sun, 16 Jul 2023 08:00:51 -0500 Subject: [PATCH] Swift cleanup: prefer case list over fallthrough in switch statements Signed-off-by: Bryan Montz Signed-off-by: William Casarin --- damus/ContentView.swift | 5 +---- damus/Models/HomeModel.swift | 7 ++----- damus/Views/Notifications/EventGroupView.swift | 3 +-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/damus/ContentView.swift b/damus/ContentView.swift index 9363a92c..685dea68 100644 --- a/damus/ContentView.swift +++ b/damus/ContentView.swift @@ -490,10 +490,7 @@ struct ContentView: View { selected_timeline = .dms damus_state.dms.set_active_dm(target.pubkey) navigationCoordinator.push(route: Route.DMChat(dms: damus_state.dms.active_model)) - case .like: fallthrough - case .zap: fallthrough - case .mention: fallthrough - case .repost: + case .like, .zap, .mention, .repost: open_event(ev: target) case .profile_zap: // Handled separately above. diff --git a/damus/Models/HomeModel.swift b/damus/Models/HomeModel.swift index c9c6ae4a..9cdfd43d 100644 --- a/damus/Models/HomeModel.swift +++ b/damus/Models/HomeModel.swift @@ -165,9 +165,7 @@ class HomeModel { } switch kind { - case .chat: fallthrough - case .longform: fallthrough - case .text: + case .chat, .longform, .text: handle_text_event(sub_id: sub_id, ev) case .contacts: handle_contact_event(sub_id: sub_id, relay_id: relay_id, ev: ev) @@ -862,8 +860,7 @@ func guard_valid_event(events: EventCache, ev: NostrEvent, callback: @escaping ( case .ok: callback() - case .bad_id: fallthrough - case .bad_sig: + case .bad_id, .bad_sig: break } } diff --git a/damus/Views/Notifications/EventGroupView.swift b/damus/Views/Notifications/EventGroupView.swift index 32051d10..9375df88 100644 --- a/damus/Views/Notifications/EventGroupView.swift +++ b/damus/Views/Notifications/EventGroupView.swift @@ -182,8 +182,7 @@ func reacting_to_verb(group: EventGroupType) -> String { return "reacted" case .repost: return "reposted" - case .zap: fallthrough - case .profile_zap: + case .zap, .profile_zap: return "zapped" } }