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