mirror of
https://github.com/mastodon/mastodon-ios
synced 2025-04-11 22:58:02 +02:00
Use shortest possible timestamp on notifications
Contributes to #399 [BUG] Multiple interactions do not collapse into a single notification
This commit is contained in:
parent
552a844582
commit
53db7079b4
@ -602,7 +602,7 @@ struct NotificationRowView: View {
|
||||
Text(string)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
case .timeSinceLabel(let date):
|
||||
Text(date.localizedAbbreviatedSlowedTimeAgoSinceNow)
|
||||
Text(date.localizedExtremelyAbbreviatedTimeElapsedUntilNow)
|
||||
.font(.subheadline)
|
||||
.frame(height: actionSuperheaderHeight)
|
||||
.fixedSize(horizontal: true, vertical: false)
|
||||
@ -628,7 +628,7 @@ struct NotificationRowView: View {
|
||||
HStack(alignment: .top, spacing: 2) {
|
||||
Text(string)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
Text(date.localizedAbbreviatedSlowedTimeAgoSinceNow)
|
||||
Text(date.localizedExtremelyAbbreviatedTimeElapsedUntilNow)
|
||||
.font(.subheadline)
|
||||
.frame(height: actionSuperheaderHeight)
|
||||
.fixedSize(horizontal: true, vertical: false)
|
||||
|
@ -9,6 +9,14 @@ import Foundation
|
||||
import MastodonAsset
|
||||
import MastodonLocalization
|
||||
|
||||
let extremeDateAbbreviatingFormatter: DateComponentsFormatter = {
|
||||
let formatter = DateComponentsFormatter()
|
||||
formatter.allowedUnits = [.year, .month, .day, .hour, .minute, .second]
|
||||
formatter.unitsStyle = .abbreviated
|
||||
formatter.maximumUnitCount = 1
|
||||
return formatter
|
||||
}()
|
||||
|
||||
extension Date {
|
||||
|
||||
static let calendar = Calendar(identifier: .gregorian)
|
||||
@ -35,6 +43,11 @@ extension Date {
|
||||
public var localizedAbbreviatedSlowedTimeAgoSinceNow: String {
|
||||
return Date.relativeTimestampFormatter.localizedString(for: self, relativeTo: Date())
|
||||
}
|
||||
|
||||
public var localizedExtremelyAbbreviatedTimeElapsedUntilNow: String {
|
||||
let interval = Date.now.timeIntervalSince(self)
|
||||
return extremeDateAbbreviatingFormatter.string(from: interval) ?? ""
|
||||
}
|
||||
}
|
||||
|
||||
extension Date {
|
||||
|
Loading…
x
Reference in New Issue
Block a user