mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-11 13:59:13 +00:00
Manually cancel timeline listeners when a RoomScreen is torn down instead of waiting for a delayed deinit
This commit is contained in:
parent
698b0aea44
commit
99d6caed4e
@ -60,6 +60,7 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
|
||||
}
|
||||
|
||||
func stop() {
|
||||
parameters.roomProxy.removeTimelineListener()
|
||||
viewModel.context.send(viewAction: .markRoomAsRead)
|
||||
}
|
||||
|
||||
|
@ -44,12 +44,12 @@ struct MockRoomProxy: RoomProxyProtocol {
|
||||
.failure(.failedRetrievingMemberAvatarURL)
|
||||
}
|
||||
|
||||
func startLiveEventListener() { }
|
||||
|
||||
func addTimelineListener(listener: TimelineListener) -> Result<[TimelineItem], RoomProxyError> {
|
||||
.failure(.failedAddingTimelineListener)
|
||||
}
|
||||
|
||||
func removeTimelineListener() { }
|
||||
|
||||
func paginateBackwards(requestSize: UInt, untilNumberOfItems: UInt) async -> Result<Void, RoomProxyError> {
|
||||
.failure(.failedPaginatingBackwards)
|
||||
}
|
||||
|
@ -34,11 +34,7 @@ class RoomProxy: RoomProxyProtocol {
|
||||
private(set) var displayName: String?
|
||||
|
||||
private var timelineObservationToken: StoppableSpawn?
|
||||
|
||||
deinit {
|
||||
timelineObservationToken?.cancel()
|
||||
}
|
||||
|
||||
|
||||
init(slidingSyncRoom: SlidingSyncRoomProtocol,
|
||||
room: RoomProtocol,
|
||||
backgroundTaskService: BackgroundTaskServiceProtocol) {
|
||||
@ -151,6 +147,11 @@ class RoomProxy: RoomProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func removeTimelineListener() {
|
||||
timelineObservationToken?.cancel()
|
||||
timelineObservationToken = nil
|
||||
}
|
||||
|
||||
func paginateBackwards(requestSize: UInt, untilNumberOfItems: UInt) async -> Result<Void, RoomProxyError> {
|
||||
do {
|
||||
try await Task.dispatch(on: .global()) {
|
||||
|
@ -60,6 +60,8 @@ protocol RoomProxyProtocol {
|
||||
|
||||
func addTimelineListener(listener: TimelineListener) -> Result<[TimelineItem], RoomProxyError>
|
||||
|
||||
func removeTimelineListener()
|
||||
|
||||
func paginateBackwards(requestSize: UInt, untilNumberOfItems: UInt) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func sendReadReceipt(for eventID: String) async -> Result<Void, RoomProxyError>
|
||||
|
Loading…
x
Reference in New Issue
Block a user