mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Prevent duplicated timeline items from crashing the diffable datasource
This commit is contained in:
committed by
Stefan Ceriu
parent
cbfd2d1cca
commit
3f900df3de
@@ -231,6 +231,8 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
var newTimelineItems = [RoomTimelineItemProtocol]()
|
||||
var canBackPaginate = true
|
||||
var isBackPaginating = false
|
||||
|
||||
var createdIdentifiers = [String: Bool]()
|
||||
|
||||
for (index, itemProxy) in timelineProvider.itemsPublisher.value.enumerated() {
|
||||
if Task.isCancelled {
|
||||
@@ -245,7 +247,13 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
switch itemProxy {
|
||||
case .event(let eventItemProxy):
|
||||
if let timelineItem = timelineItemFactory.buildTimelineItemFor(eventItemProxy: eventItemProxy, groupState: groupState) {
|
||||
newTimelineItems.append(timelineItem)
|
||||
#warning("This works around duplicated items coming out of the SDK, remove once fixed")
|
||||
if createdIdentifiers[timelineItem.id] == nil {
|
||||
newTimelineItems.append(timelineItem)
|
||||
createdIdentifiers[timelineItem.id] = true
|
||||
} else {
|
||||
MXLog.error("Found duplicated timeline item, ignoring")
|
||||
}
|
||||
}
|
||||
case .virtual(let virtualItem):
|
||||
switch virtualItem {
|
||||
@@ -274,7 +282,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
if Task.isCancelled {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
timelineItems = newTimelineItems
|
||||
|
||||
callbacks.send(.updatedTimelineItems)
|
||||
|
||||
Reference in New Issue
Block a user