From 188c6363fc82a4e877e49a09eb33df0b2b7577ca Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Wed, 19 Mar 2025 18:51:41 +0200 Subject: [PATCH] Attempt to fix the wrong timeline start display by defaulting the backwards publisher to .idle The default values shouldn't matter as they should be updated when calling subscribeToPagination but empirically we randomly see the timeline start virtual item when we shouldn't. We believe there's a race condition between the default values the status publisher so we're going to default the backwards one to .idle. Worst case it's going to do one extra back pagination. --- ElementX/Sources/Services/Timeline/TimelineProxy.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ElementX/Sources/Services/Timeline/TimelineProxy.swift b/ElementX/Sources/Services/Timeline/TimelineProxy.swift index 086454cb9..420b9da02 100644 --- a/ElementX/Sources/Services/Timeline/TimelineProxy.swift +++ b/ElementX/Sources/Services/Timeline/TimelineProxy.swift @@ -14,8 +14,12 @@ final class TimelineProxy: TimelineProxyProtocol { private var backPaginationStatusObservationToken: TaskHandle? - // The default values don't matter here, they will be updated when calling subscribeToPagination. - private let backPaginationStatusSubject = CurrentValueSubject(.timelineEndReached) + // The default values shouldn't matter here as they will be updated when calling subscribeToPagination + // but empirically we randomly see the timeline start virtual item when we shouldn't. + // We believe there's a race condition between the default values the status publisher + // so we're going to default the backwards one to .idle. Worst case it's going to do + // one extra back pagination. + private let backPaginationStatusSubject = CurrentValueSubject(.idle) private let forwardPaginationStatusSubject = CurrentValueSubject(.timelineEndReached) private let kind: TimelineKind