Files
damus/damus/Types/DamusDuration.swift
Charlie Fish 068b89d087 mute: adding new structs/enums for new mute list
- Adding MuteItem & DamusDuration
- Changing RefId hashtag associated type from TagElem to Hashtag
    - This is done because in MuteItem, we can not create a RefId.hashtag TagElem instance since we don’t have a note associated with a given hashtag mute item.

Related: https://github.com/damus-io/damus/issues/1718
Related: https://github.com/damus-io/damus/issues/856
Lighting Address: fishcharlie@strike.me

Signed-off-by: Charlie Fish <contact@charlie.fish>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2024-01-25 12:12:57 -08:00

39 lines
1.3 KiB
Swift

//
// DamusDuration.swift
// damus
//
// Created by Charlie Fish on 1/13/24.
//
import Foundation
enum DamusDuration: CaseIterable {
case day
case week
case month
var title: String {
switch self {
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:
return NSLocalizedString("1 week", comment: "A duration of 1 week to be shown to the user. Most likely in the context of how long they want to mute a piece of content for.")
case .month:
return NSLocalizedString("1 month", comment: "A duration of 1 month to be shown to the user. Most likely in the context of how long they want to mute a piece of content for.")
}
}
var date_from_now: Date? {
let current_date = Date()
switch self {
case .day:
return Calendar.current.date(byAdding: .day, value: 1, to: current_date)
case .week:
return Calendar.current.date(byAdding: .day, value: 7, to: current_date)
case .month:
return Calendar.current.date(byAdding: .month, value: 1, to: current_date)
}
}
}