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) .foregroundColor(theme.tintColor)
.frame(width: 10, height: 10) .frame(width: 10, height: 10)
} }
Text(conversation.lastStatus.createdAt.formatted) Text(conversation.lastStatus.createdAt.relativeFormatted)
.font(.scaledFootnote) .font(.scaledFootnote)
} }
Text(conversation.lastStatus.content.asRawText) Text(conversation.lastStatus.content.asRawText)

View File

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

View File

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

View File

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

View File

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