Background execution (#100)

* #99 Implement background tasks

* #99 Add changelog

* #99 Fix some code smells

* #99 Use background tasks in room timeline controller

* #99 Move background task service into room proxy and media provider
This commit is contained in:
ismailgulek
2022-06-29 13:03:28 +03:00
committed by GitHub
parent d74158ced1
commit dbee1924eb
13 changed files with 619 additions and 9 deletions
@@ -26,6 +26,7 @@ private class WeakClientProxyWrapper: ClientDelegate {
class ClientProxy: ClientProxyProtocol {
private let client: Client
private let backgroundTaskService: BackgroundTaskServiceProtocol
private(set) var rooms: [RoomProxy] = [] {
didSet {
@@ -39,8 +40,10 @@ class ClientProxy: ClientProxyProtocol {
let callbacks = PassthroughSubject<ClientProxyCallback, Never>()
init(client: Client) {
init(client: Client,
backgroundTaskService: BackgroundTaskServiceProtocol) {
self.client = client
self.backgroundTaskService = backgroundTaskService
client.setDelegate(delegate: WeakClientProxyWrapper(clientProxy: self))
@@ -119,7 +122,9 @@ class ClientProxy: ClientProxyProtocol {
MXLog.error("Failed retrieving sdk room with id: \(id)")
break
}
currentRooms.append(RoomProxy(room: sdkRoom, roomMessageFactory: RoomMessageFactory()))
currentRooms.append(RoomProxy(room: sdkRoom,
roomMessageFactory: RoomMessageFactory(),
backgroundTaskService: backgroundTaskService))
case .remove(_, let id, _):
currentRooms.removeAll { $0.id == id }
}