mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
vector-im/element-x-ios/issues/53 - Adopt MainActors, dispatch heavy operations do detached tasks and ensure combine publisher call back on the right queue
This commit is contained in:
committed by
Stefan Ceriu
parent
dde7786152
commit
f5890b68a2
@@ -85,16 +85,12 @@ final class HomeScreenCoordinator: Coordinator, Presentable {
|
||||
Task {
|
||||
if case let .success(userAvatarURL) = await parameters.userSession.loadUserAvatarURL() {
|
||||
if case let .success(avatar) = await parameters.mediaProvider.loadImageFromURL(userAvatarURL) {
|
||||
await MainActor.run {
|
||||
self.viewModel.updateWithUserAvatar(avatar)
|
||||
}
|
||||
self.viewModel.updateWithUserAvatar(avatar)
|
||||
}
|
||||
}
|
||||
|
||||
if case let .success(userDisplayName) = await parameters.userSession.loadUserDisplayName() {
|
||||
await MainActor.run {
|
||||
self.viewModel.updateWithUserDisplayName(userDisplayName)
|
||||
}
|
||||
self.viewModel.updateWithUserDisplayName(userDisplayName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,11 +47,11 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
override func process(viewAction: HomeScreenViewAction) {
|
||||
switch viewAction {
|
||||
case .logout:
|
||||
self.completion?(.logout)
|
||||
completion?(.logout)
|
||||
case .loadRoomData(let roomIdentifier):
|
||||
self.loadRoomDataForIdentifier(roomIdentifier)
|
||||
loadRoomDataForIdentifier(roomIdentifier)
|
||||
case .selectRoom(let roomIdentifier):
|
||||
self.completion?(.selectRoom(roomIdentifier: roomIdentifier))
|
||||
completion?(.selectRoom(roomIdentifier: roomIdentifier))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
@MainActor
|
||||
protocol HomeScreenViewModelProtocol {
|
||||
var completion: ((HomeScreenViewModelResult) -> Void)? { get set }
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@MainActor
|
||||
protocol LoginScreenViewModelProtocol {
|
||||
var completion: ((LoginScreenViewModelResult) -> Void)? { get set }
|
||||
var context: LoginScreenViewModelType.Context { get }
|
||||
|
||||
@@ -39,7 +39,7 @@ struct RoomScreenViewState: BindableState {
|
||||
var isBackPaginating = false
|
||||
var bindings: RoomScreenViewStateBindings
|
||||
|
||||
var contextMenuBuilder: ((_ itemId: String) -> TimelineItemContextMenu)?
|
||||
var contextMenuBuilder: (@MainActor (_ itemId: String) -> TimelineItemContextMenu)?
|
||||
|
||||
var sendButtonDisabled: Bool {
|
||||
bindings.composerText.count == 0
|
||||
|
||||
@@ -67,15 +67,11 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
Task {
|
||||
switch viewAction {
|
||||
case .loadPreviousPage:
|
||||
await MainActor.run {
|
||||
state.isBackPaginating = true
|
||||
}
|
||||
state.isBackPaginating = true
|
||||
|
||||
switch await timelineController.paginateBackwards(Constants.backPaginationPageSize) {
|
||||
default:
|
||||
await MainActor.run {
|
||||
state.isBackPaginating = false
|
||||
}
|
||||
state.isBackPaginating = false
|
||||
}
|
||||
|
||||
case .itemAppeared(let id):
|
||||
@@ -90,10 +86,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
}
|
||||
|
||||
await timelineController.sendMessage(state.bindings.composerText)
|
||||
|
||||
await MainActor.run {
|
||||
state.bindings.composerText = ""
|
||||
}
|
||||
state.bindings.composerText = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@MainActor
|
||||
protocol RoomScreenViewModelProtocol {
|
||||
var context: RoomScreenViewModelType.Context { get }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user