Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions FlowCrypt/Common UI/AttachmentManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import UIKit
import Combine

@MainActor
protocol AttachmentManagerType {
func open(_ attachment: MessageAttachment)
}
Expand Down Expand Up @@ -50,19 +49,13 @@ extension AttachmentManager: AttachmentManagerType {
.sinkFuture(
receiveValue: {},
receiveError: { [weak self] error in
self?.handle(error)
self?.controller?.showToast(
"\("message_attachment_saved_with_error".localized) \(error.localizedDescription)"
)
}
)
.store(in: &self.cancellable)
}

private func handle(_ error: Error) {
Task {
await controller?.showToast(
"\("message_attachment_saved_with_error".localized) \(error.localizedDescription)"
)
}
}
}

// MARK: - FilesManagerPresenter
Expand Down
8 changes: 4 additions & 4 deletions FlowCrypt/Common UI/Refreshable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

@MainActor
protocol Refreshable {
func startRefreshing()
}
protocol Refreshable {

func startRefreshing()
}
2 changes: 2 additions & 0 deletions FlowCrypt/Controllers/Compose/ComposeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ private struct ComposedDraft: Equatable {
* - User can be redirected here from *InboxViewController* by tapping on *+*
* - Or from *ThreadDetailsViewController* controller by tapping on *reply*
**/
@MainActor
final class ComposeViewController: TableNodeViewController {
private lazy var logger = Logger.nested(Self.self)

Expand Down Expand Up @@ -931,6 +932,7 @@ extension ComposeViewController: PHPickerViewControllerDelegate {
})
}
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class InboxViewContainerController: TableNodeViewController {
let folderService: FoldersServiceType
let decorator: InboxViewControllerContainerDecorator

private var state: State = .loading {
@MainActor private var state: State = .loading {
didSet { handleNewState() }
}

Expand Down Expand Up @@ -68,7 +68,7 @@ final class InboxViewContainerController: TableNodeViewController {
}
}

private func handleFetched(folders: [FolderViewModel]) {
@MainActor private func handleFetched(folders: [FolderViewModel]) {
guard folders.isNotEmpty else {
state = .empty
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Foundation
import UIKit

class InboxViewControllerFactory {
@MainActor
static func make(with viewModel: InboxViewModel) -> InboxViewController {
guard let currentAuthType = DataService.shared.currentAuthType else {
fatalError("Internal inconsistency")
Expand Down
1 change: 0 additions & 1 deletion FlowCrypt/Controllers/Inbox/InboxViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import FlowCryptCommon
import FlowCryptUI
import Foundation

@MainActor
final class InboxViewController: ASDKViewController<ASDisplayNode> {
private lazy var logger = Logger.nested(Self.self)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import UIKit

@MainActor
protocol MsgListViewController {
func open(with message: InboxRenderable, path: String)

Expand All @@ -31,9 +30,11 @@ extension MsgListViewController where Self: UIViewController {
private func openDraft(with message: Message) {
guard let email = DataService.shared.email else { return }

let controller = ComposeViewController(email: email)
controller.updateWithMessage(message: message)
navigationController?.pushViewController(controller, animated: true)
Task {
let controller = await ComposeViewController(email: email)
await controller.updateWithMessage(message: message)
await navigationController?.pushViewController(controller, animated: true)
}
}

private func openMsg(with message: Message, path: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ enum BackupOption: Int, CaseIterable, Equatable {
}
}

@MainActor
final class BackupOptionsViewController: ASDKViewController<TableNode> {
enum Parts: Int, CaseIterable {
case email, download, action, info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import AsyncDisplayKit
import FlowCryptUI

@MainActor
final class BackupViewController: ASDKViewController<TableNode> {
private enum Parts: Int, CaseIterable {
case info, action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import AsyncDisplayKit
import FlowCryptUI
import Foundation

@MainActor
final class BackupSelectKeyViewController: ASDKViewController<TableNode> {
private let backupService: BackupServiceType
private let service: ServiceActor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import FlowCryptUI
* - User can proceed to importing keys *SetupManuallyImportKeyViewController*
* - User can see detail information for the key in *KeyDetailViewController*
*/
@MainActor
final class KeySettingsViewController: TableNodeViewController {
private var keys: [KeyDetails] = []
private let decorator: KeySettingsViewDecorator
Expand Down
1 change: 0 additions & 1 deletion FlowCrypt/Controllers/Setup/PassPhraseSaveable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import FlowCryptUI

@MainActor
protocol PassPhraseSaveable {
var storageMethod: StorageMethod { get set }
var passPhraseIndexes: [IndexPath] { get }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum CreateKeyError: Error {
* - Here user can enter a pass phrase (can be saved in memory or in encrypted storage) and generate a key
* - After key is generated, user will be redirected to **main flow** (inbox view)
*/
@MainActor
final class SetupGenerateKeyViewController: SetupCreatePassphraseAbstractViewController {

private let backupService: BackupServiceType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ final class SetupManuallyImportKeyViewController: TableNodeViewController {
}

private func updateSubtitle() {
node.reloadRows(at: [Parts.description.indexPath], with: .fade)
DispatchQueue.main.async {
self.node.reloadRows(at: [Parts.description.indexPath], with: .fade)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,13 @@ extension SetupImapViewController {
do {
try await self.imap.connectImap(session: imapSessionToCheck)
try await self.imap.connectSmtp(session: smtpSession)
handleSuccessfulConnection()
DispatchQueue.main.async {
self.handleSuccessfulConnection()
}
} catch {
handleConnection(error: error)
DispatchQueue.main.async {
self.handleConnection(error: error)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import ENSwiftSideMenu
import FlowCryptUI
import UIKit

@MainActor
protocol SideMenuViewController {
func didOpen()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import FlowCryptUI
* On tap on each folder user should be redirected to `InboxViewController` with selected folder
* On settings tap user will be redirected to `SettingsViewController`
*/
@MainActor
final class MyMenuViewController: ASDKViewController<ASDisplayNode> {
private enum Constants {
static let allMail = "folder_all_mail".localized
Expand Down Expand Up @@ -175,9 +174,13 @@ extension MyMenuViewController {
Task {
do {
let folders = try await foldersProvider.fetchFolders(isForceReload: true)
handleNewFolders(with: folders)
DispatchQueue.main.async {
self.handleNewFolders(with: folders)
}
} catch {
handleError(with: error)
DispatchQueue.main.async {
self.handleError(with: error)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import UIKit

@MainActor
protocol NavigationChildController {
var navigationItem: UINavigationItem { get }
var shouldShowBackButton: Bool { get }
Expand Down
27 changes: 16 additions & 11 deletions FlowCrypt/Controllers/Threads/MessageActionsHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import UIKit
import FlowCryptUI
import FlowCryptCommon

@MainActor
protocol MessageActionsHandler: AnyObject {
var currentFolderPath: String { get }
var trashFolderProvider: TrashFolderProviderType { get }
Expand All @@ -34,7 +33,9 @@ extension MessageActionsHandler where Self: UIViewController {
Task {
do {
let path = try await trashFolderProvider.getTrashFolderPath()
setupNavigationBarItems(with: path)
DispatchQueue.main.async {
self.setupNavigationBarItems(with: path)
}
} catch {
// todo - handle?
logger.logError("setupNavigationBar: \(error)")
Expand Down Expand Up @@ -94,18 +95,22 @@ extension MessageActionsHandler where Self: UIViewController {
Task {
do {
let trashPath = try await trashFolderProvider.getTrashFolderPath()
guard let trashPath = trashPath else {
return
}
if self.currentFolderPath.caseInsensitiveCompare(trashPath) == .orderedSame {
self.awaitUserConfirmation { [weak self] in
self?.permanentlyDelete()
DispatchQueue.main.async {
guard let trashPath = trashPath else {
return
}
if self.currentFolderPath.caseInsensitiveCompare(trashPath) == .orderedSame {
self.awaitUserConfirmation { [weak self] in
self?.permanentlyDelete()
}
} else {
self.moveToTrash(with: trashPath)
}
} else {
self.moveToTrash(with: trashPath)
}
} catch {
showToast(error.localizedDescription)
DispatchQueue.main.async {
self.showToast(error.localizedDescription)
}
}
}
}
Expand Down
55 changes: 29 additions & 26 deletions FlowCrypt/Extensions/UIViewController+Spinner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Roma Sosnovsky on 25/10/21
// Copyright © 2017-present FlowCrypt a. s. All rights reserved.
//

import MBProgressHUD
import UIKit

Expand All @@ -14,44 +14,47 @@ extension UIViewController {
MBProgressHUD.forView(view) ?? MBProgressHUD.showAdded(to: view, animated: true)
}

@MainActor
func showSpinner(_ message: String = "loading_title".localized, isUserInteractionEnabled: Bool = false) {
guard self.view.subviews.first(where: { $0 is MBProgressHUD }) == nil else {
// hud is already shown
return
}
self.view.isUserInteractionEnabled = isUserInteractionEnabled
DispatchQueue.main.async {
guard self.view.subviews.first(where: { $0 is MBProgressHUD }) == nil else {
// hud is already shown
return
}
self.view.isUserInteractionEnabled = isUserInteractionEnabled

let spinner = MBProgressHUD.showAdded(to: self.view, animated: true)
spinner.label.text = message
spinner.isUserInteractionEnabled = isUserInteractionEnabled
let spinner = MBProgressHUD.showAdded(to: self.view, animated: true)
spinner.label.text = message
spinner.isUserInteractionEnabled = isUserInteractionEnabled
}
}

@MainActor
func updateSpinner(label: String = "compose_uploading".localized,
progress: Float? = nil,
systemImageName: String? = nil) {
if let progress = progress {
if progress >= 1, let imageName = systemImageName {
self.updateSpinner(label: "compose_sent".localized,
systemImageName: imageName)
DispatchQueue.main.async {
if let progress = progress {
if progress >= 1, let imageName = systemImageName {
self.updateSpinner(label: "compose_sent".localized,
systemImageName: imageName)
} else {
self.showProgressHUD(progress: progress, label: label)
}
} else if let imageName = systemImageName {
self.showProgressHUDWithCustomImage(imageName: imageName, label: label)
} else {
self.showProgressHUD(progress: progress, label: label)
self.currentProgressHUD.mode = .indeterminate
self.currentProgressHUD.label.text = label
}
} else if let imageName = systemImageName {
self.showProgressHUDWithCustomImage(imageName: imageName, label: label)
} else {
self.currentProgressHUD.mode = .indeterminate
self.currentProgressHUD.label.text = label
}
}

@MainActor
func hideSpinner() {
self.view.subviews
.compactMap { $0 as? MBProgressHUD }
.forEach { $0.hide(animated: true) }
self.view.isUserInteractionEnabled = true
DispatchQueue.main.async {
self.view.subviews
.compactMap { $0 as? MBProgressHUD }
.forEach { $0.hide(animated: true) }
self.view.isUserInteractionEnabled = true
}
}
}

Expand Down
Loading