mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
implemented the display logic for the formatted date
This commit is contained in:
@@ -39,6 +39,11 @@ final class RoomTimelineItemViewState: Identifiable, Equatable, ObservableObject
|
||||
var id: TimelineItemIdentifier.UniqueID {
|
||||
identifier.uniqueID
|
||||
}
|
||||
|
||||
/// The timestamp of the item if available (separator date or event timestamp), `nil` otherwise.
|
||||
var timestamp: Date? {
|
||||
type.timestamp
|
||||
}
|
||||
}
|
||||
|
||||
enum RoomTimelineItemType: Equatable {
|
||||
@@ -147,4 +152,55 @@ enum RoomTimelineItemType: Equatable {
|
||||
return item.id
|
||||
}
|
||||
}
|
||||
|
||||
/// The timestamp of the item if available.
|
||||
/// Returns the separator date for `.separator`, the event timestamp for all event-based
|
||||
/// items, the timestamp of the first event inside a `.group`, and `nil` for virtual items
|
||||
/// that carry no timestamp (read marker, pagination indicator, timeline start).
|
||||
var timestamp: Date? {
|
||||
switch self {
|
||||
case .separator(let item):
|
||||
return item.timestamp
|
||||
case .text(let item):
|
||||
return item.timestamp
|
||||
case .image(let item):
|
||||
return item.timestamp
|
||||
case .video(let item):
|
||||
return item.timestamp
|
||||
case .audio(let item):
|
||||
return item.timestamp
|
||||
case .file(let item):
|
||||
return item.timestamp
|
||||
case .emote(let item):
|
||||
return item.timestamp
|
||||
case .notice(let item):
|
||||
return item.timestamp
|
||||
case .redacted(let item):
|
||||
return item.timestamp
|
||||
case .encrypted(let item):
|
||||
return item.timestamp
|
||||
case .sticker(let item):
|
||||
return item.timestamp
|
||||
case .unsupported(let item):
|
||||
return item.timestamp
|
||||
case .state(let item):
|
||||
return item.timestamp
|
||||
case .location(let item):
|
||||
return item.timestamp
|
||||
case .poll(let item):
|
||||
return item.timestamp
|
||||
case .voice(let item):
|
||||
return item.timestamp
|
||||
case .callInvite(let item):
|
||||
return item.timestamp
|
||||
case .callNotification(let item):
|
||||
return item.timestamp
|
||||
case .liveLocation(let item):
|
||||
return item.timestamp
|
||||
case .group(let item):
|
||||
return (item.items.first(where: { $0 is EventBasedTimelineItemProtocol }) as? EventBasedTimelineItemProtocol)?.timestamp
|
||||
case .readMarker, .paginationIndicator, .timelineStart:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user