mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Fix strong reference cycle between RoomProxy and RoomTimelineProvider
This commit is contained in:
committed by
Stefan Ceriu
parent
40d80e1b90
commit
e2af796d4a
@@ -35,11 +35,6 @@ class RoomProxy: RoomProxyProtocol {
|
|||||||
private(set) var displayName: String?
|
private(set) var displayName: String?
|
||||||
|
|
||||||
private var backPaginationOutcome: PaginationOutcome?
|
private var backPaginationOutcome: PaginationOutcome?
|
||||||
private(set) lazy var timelineProvider: RoomTimelineProviderProtocol = {
|
|
||||||
let provider = RoomTimelineProvider(roomProxy: self)
|
|
||||||
addTimelineListener(listener: WeakRoomTimelineProviderWrapper(timelineProvider: provider))
|
|
||||||
return provider
|
|
||||||
}()
|
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
room.removeTimeline()
|
room.removeTimeline()
|
||||||
@@ -146,7 +141,7 @@ class RoomProxy: RoomProxyProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func addTimelineListener(listener: TimelineListener) {
|
func addTimelineListener(listener: TimelineListener) {
|
||||||
room.addTimelineListener(listener: listener)
|
room.addTimelineListener(listener: listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ protocol RoomProxyProtocol {
|
|||||||
|
|
||||||
var avatarURL: String? { get }
|
var avatarURL: String? { get }
|
||||||
|
|
||||||
var timelineProvider: RoomTimelineProviderProtocol { get }
|
|
||||||
|
|
||||||
func avatarURLStringForUserId(_ userId: String) -> String?
|
func avatarURLStringForUserId(_ userId: String) -> String?
|
||||||
|
|
||||||
func loadAvatarURLForUserId(_ userId: String) async -> Result<String?, RoomProxyError>
|
func loadAvatarURLForUserId(_ userId: String) async -> Result<String?, RoomProxyError>
|
||||||
@@ -56,6 +54,8 @@ protocol RoomProxyProtocol {
|
|||||||
|
|
||||||
func loadDisplayName() async -> Result<String, RoomProxyError>
|
func loadDisplayName() async -> Result<String, RoomProxyError>
|
||||||
|
|
||||||
|
func addTimelineListener(listener: TimelineListener)
|
||||||
|
|
||||||
func paginateBackwards(count: UInt) async -> Result<Void, RoomProxyError>
|
func paginateBackwards(count: UInt) async -> Result<Void, RoomProxyError>
|
||||||
|
|
||||||
func sendMessage(_ message: String, inReplyToEventId: String?) async -> Result<Void, RoomProxyError>
|
func sendMessage(_ message: String, inReplyToEventId: String?) async -> Result<Void, RoomProxyError>
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ class RoomTimelineProvider: RoomTimelineProviderProtocol {
|
|||||||
init(roomProxy: RoomProxyProtocol) {
|
init(roomProxy: RoomProxyProtocol) {
|
||||||
self.roomProxy = roomProxy
|
self.roomProxy = roomProxy
|
||||||
itemProxies = []
|
itemProxies = []
|
||||||
|
|
||||||
|
Task {
|
||||||
|
await roomProxy.addTimelineListener(listener: WeakRoomTimelineProviderWrapper(timelineProvider: self))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func paginateBackwards(_ count: UInt) async -> Result<Void, RoomTimelineProviderError> {
|
func paginateBackwards(_ count: UInt) async -> Result<Void, RoomTimelineProviderError> {
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ class UserSessionFlowCoordinator: Coordinator {
|
|||||||
|
|
||||||
let timelineController = RoomTimelineController(userId: userId,
|
let timelineController = RoomTimelineController(userId: userId,
|
||||||
roomId: roomIdentifier,
|
roomId: roomIdentifier,
|
||||||
timelineProvider: roomProxy.timelineProvider,
|
timelineProvider: RoomTimelineProvider(roomProxy: roomProxy),
|
||||||
timelineItemFactory: timelineItemFactory,
|
timelineItemFactory: timelineItemFactory,
|
||||||
mediaProvider: userSession.mediaProvider,
|
mediaProvider: userSession.mediaProvider,
|
||||||
roomProxy: roomProxy)
|
roomProxy: roomProxy)
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Fix strong reference cycle between RoomProxy and RoomTimelineProvider
|
||||||
Reference in New Issue
Block a user