Always display relative date in the timeline

This commit is contained in:
Thomas Ricouard 2023-01-22 20:14:05 +01:00
parent 88ac6e1de5
commit ce41e6b000
5 changed files with 7 additions and 11 deletions

View file

@ -31,7 +31,7 @@ struct ConversationsListRow: View {
.foregroundColor(theme.tintColor)
.frame(width: 10, height: 10)
}
Text(conversation.lastStatus.createdAt.formatted)
Text(conversation.lastStatus.createdAt.relativeFormatted)
.font(.scaledFootnote)
}
Text(conversation.lastStatus.content.asRawText)

View file

@ -29,12 +29,8 @@ extension ServerDate {
Self.createdAtDateFormatter.date(from: self)!
}
public var formatted: String {
if Self.calendar.numberOfDaysBetween(asDate, and: Date()) > 1 {
return Self.createdAtShortDateFormatted.string(from: asDate)
} else {
return Self.createdAtRelativeFormatter.localizedString(for: asDate, relativeTo: Date())
}
public var relativeFormatted: String {
return Self.createdAtRelativeFormatter.localizedString(for: asDate, relativeTo: Date())
}
}

View file

@ -62,7 +62,7 @@ struct NotificationRowView: View {
.font(.scaledFootnote)
.fontWeight(.regular)
.foregroundColor(.gray) +
Text(notification.createdAt.formatted)
Text(notification.createdAt.relativeFormatted)
.font(.scaledFootnote)
.fontWeight(.regular)
.foregroundColor(.gray)

View file

@ -41,7 +41,7 @@ public struct StatusEmbeddedView: View {
Group {
Text("@\(account.acct)") +
Text("") +
Text(status.reblog?.createdAt.formatted ?? status.createdAt.formatted)
Text(status.reblog?.createdAt.relativeFormatted ?? status.createdAt.relativeFormatted)
}
.font(.scaledCaption)
.foregroundColor(.gray)

View file

@ -197,7 +197,7 @@ public struct StatusRowView: View {
.accessibilityHidden(true)
}
.accessibilityElement()
.accessibilityLabel(Text("\(status.account.displayName), \(status.createdAt.formatted)"))
.accessibilityLabel(Text("\(status.account.displayName), \(status.createdAt.relativeFormatted)"))
}
makeStatusContentView(status: status)
.contentShape(Rectangle())
@ -266,7 +266,7 @@ public struct StatusRowView: View {
Group {
Text("@\(status.account.acct)") +
Text("") +
Text(status.createdAt.formatted) +
Text(status.createdAt.relativeFormatted) +
Text("") +
Text(Image(systemName: viewModel.status.visibility.iconName))
}