mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
vector-im/element-x-ios/issues/53 - Converted most callback based methods to async/await
This commit is contained in:
committed by
Stefan Ceriu
parent
f2fe39eca7
commit
dde7786152
@@ -65,19 +65,21 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
roomUpdateListeners.removeAll()
|
||||
|
||||
roomList.forEach({ roomSummary in
|
||||
roomSummary.callbacks.sink { [weak self] callback in
|
||||
guard let self = self else {
|
||||
return
|
||||
}
|
||||
|
||||
switch callback {
|
||||
case .updatedData:
|
||||
if let index = self.state.rooms.firstIndex(where: { $0.id == roomSummary.id }) {
|
||||
self.state.rooms[index] = self.buildOrUpdateRoomFromSummary(roomSummary)
|
||||
roomSummary.callbacks
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] callback in
|
||||
guard let self = self else {
|
||||
return
|
||||
}
|
||||
|
||||
switch callback {
|
||||
case .updatedData:
|
||||
if let index = self.state.rooms.firstIndex(where: { $0.id == roomSummary.id }) {
|
||||
self.state.rooms[index] = self.buildOrUpdateRoomFromSummary(roomSummary)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.store(in: &roomUpdateListeners)
|
||||
.store(in: &roomUpdateListeners)
|
||||
})
|
||||
|
||||
}
|
||||
@@ -98,7 +100,9 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
return
|
||||
}
|
||||
|
||||
roomSummary.loadData()
|
||||
Task {
|
||||
await roomSummary.loadDetails()
|
||||
}
|
||||
}
|
||||
|
||||
private func buildOrUpdateRoomFromSummary(_ roomSummary: RoomSummaryProtocol) -> HomeScreenRoom {
|
||||
|
||||
Reference in New Issue
Block a user