diff --git a/damus/Types/DamusDuration.swift b/damus/Types/DamusDuration.swift index fa499b41..22e68a0f 100644 --- a/damus/Types/DamusDuration.swift +++ b/damus/Types/DamusDuration.swift @@ -8,12 +8,15 @@ import Foundation enum DamusDuration: CaseIterable { + case indefinite case day case week case month var title: String { switch self { + case .indefinite: + return NSLocalizedString("Indefinite", comment: "Mute a given item indefinitly (until user unmutes it). As opposed to muting the item for a given period of time.") case .day: return NSLocalizedString("24 hours", comment: "A duration of 24 hours/1 day to be shown to the user. Most likely in the context of how long they want to mute a piece of content for.") case .week: @@ -27,6 +30,8 @@ enum DamusDuration: CaseIterable { let current_date = Date() switch self { + case .indefinite: + return nil case .day: return Calendar.current.date(byAdding: .day, value: 1, to: current_date) case .week: diff --git a/damus/Views/Muting/AddMuteItemView.swift b/damus/Views/Muting/AddMuteItemView.swift index 428611da..ad4e923d 100644 --- a/damus/Views/Muting/AddMuteItemView.swift +++ b/damus/Views/Muting/AddMuteItemView.swift @@ -9,7 +9,7 @@ import SwiftUI struct AddMuteItemView: View { let state: DamusState @State var new_text: String = "" - @State var expiration: DamusDuration? + @State var expiration: DamusDuration = .indefinite @Environment(\.dismiss) var dismiss @@ -23,7 +23,6 @@ struct AddMuteItemView: View { .padding(.bottom) Picker(selection: $expiration) { - Text("Indefinite", comment: "Mute a given item indefinitly (until user unmutes it). As opposed to muting the item for a given period of time.") ForEach(DamusDuration.allCases, id: \.self) { duration in Text(duration.title).tag(duration) } @@ -55,7 +54,7 @@ struct AddMuteItemView: View { .cornerRadius(10) Button(action: { - let expiration_date: Date? = self.expiration?.date_from_now + let expiration_date: Date? = self.expiration.date_from_now let mute_item: MuteItem? = { if new_text.starts(with: "npub") { if let pubkey: Pubkey = bech32_pubkey_decode(new_text) {