mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Make room proxy unsubscriptions explicit. Fixes problems in which creating and deallocating room proxies would unexpectedly unsubscribe other proxies.
This commit is contained in:
@@ -58,7 +58,12 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
actionsSubject.eraseToAnyPublisher()
|
actionsSubject.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
|
|
||||||
private var roomProxy: RoomProxyProtocol?
|
private var roomProxy: RoomProxyProtocol? {
|
||||||
|
didSet {
|
||||||
|
oldValue?.unsubscribeFromUpdates()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var timelineController: RoomTimelineControllerProtocol?
|
private var timelineController: RoomTimelineControllerProtocol?
|
||||||
|
|
||||||
init(userSession: UserSessionProtocol,
|
init(userSession: UserSessionProtocol,
|
||||||
|
|||||||
@@ -1864,6 +1864,18 @@ class RoomProxyMock: RoomProxyProtocol {
|
|||||||
subscribeForUpdatesCallsCount += 1
|
subscribeForUpdatesCallsCount += 1
|
||||||
await subscribeForUpdatesClosure?()
|
await subscribeForUpdatesClosure?()
|
||||||
}
|
}
|
||||||
|
//MARK: - unsubscribeFromUpdates
|
||||||
|
|
||||||
|
var unsubscribeFromUpdatesCallsCount = 0
|
||||||
|
var unsubscribeFromUpdatesCalled: Bool {
|
||||||
|
return unsubscribeFromUpdatesCallsCount > 0
|
||||||
|
}
|
||||||
|
var unsubscribeFromUpdatesClosure: (() -> Void)?
|
||||||
|
|
||||||
|
func unsubscribeFromUpdates() {
|
||||||
|
unsubscribeFromUpdatesCallsCount += 1
|
||||||
|
unsubscribeFromUpdatesClosure?()
|
||||||
|
}
|
||||||
//MARK: - redact
|
//MARK: - redact
|
||||||
|
|
||||||
var redactCallsCount = 0
|
var redactCallsCount = 0
|
||||||
|
|||||||
@@ -51,10 +51,6 @@ class RoomProxy: RoomProxyProtocol {
|
|||||||
room.ownUserId()
|
room.ownUserId()
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
|
||||||
roomListItem.unsubscribe()
|
|
||||||
}
|
|
||||||
|
|
||||||
init(roomListItem: RoomListItemProtocol,
|
init(roomListItem: RoomListItemProtocol,
|
||||||
room: RoomProtocol,
|
room: RoomProtocol,
|
||||||
backgroundTaskService: BackgroundTaskServiceProtocol) async {
|
backgroundTaskService: BackgroundTaskServiceProtocol) async {
|
||||||
@@ -89,6 +85,10 @@ class RoomProxy: RoomProxyProtocol {
|
|||||||
|
|
||||||
subscribeToRoomStateUpdates()
|
subscribeToRoomStateUpdates()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func unsubscribeFromUpdates() {
|
||||||
|
roomListItem.unsubscribe()
|
||||||
|
}
|
||||||
|
|
||||||
lazy var id: String = room.id()
|
lazy var id: String = room.id()
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ protocol RoomProxyProtocol {
|
|||||||
|
|
||||||
func subscribeForUpdates() async
|
func subscribeForUpdates() async
|
||||||
|
|
||||||
|
func unsubscribeFromUpdates()
|
||||||
|
|
||||||
func redact(_ eventID: String) async -> Result<Void, RoomProxyError>
|
func redact(_ eventID: String) async -> Result<Void, RoomProxyError>
|
||||||
|
|
||||||
func reportContent(_ eventID: String, reason: String?) async -> Result<Void, RoomProxyError>
|
func reportContent(_ eventID: String, reason: String?) async -> Result<Void, RoomProxyError>
|
||||||
|
|||||||
Reference in New Issue
Block a user