2
2
mirror of https://github.com/mastodon/mastodon-ios synced 2025-04-11 22:58:02 +02:00

Do not show seconds in notification timestamp, only “now” if < 1 minute

Contributes to #399 [BUG] Multiple interactions do not collapse into a single notification
This commit is contained in:
shannon 2025-03-11 10:54:22 -04:00
parent 4721dd102a
commit 77f81e5849

View File

@ -11,7 +11,7 @@ import MastodonLocalization
let extremeDateAbbreviatingFormatter: DateComponentsFormatter = {
let formatter = DateComponentsFormatter()
formatter.allowedUnits = [.day, .hour, .minute, .second]
formatter.allowedUnits = [.day, .hour, .minute]
formatter.unitsStyle = .abbreviated
formatter.maximumUnitCount = 1
return formatter
@ -46,6 +46,7 @@ extension Date {
public var localizedExtremelyAbbreviatedTimeElapsedUntilNow: String {
let interval = Date.now.timeIntervalSince(self)
guard interval > TimeInterval(integerLiteral: 60) else { return "now" }
return extremeDateAbbreviatingFormatter.string(from: interval) ?? ""
}
}