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