diff --git a/Cryptomator.xcodeproj/project.pbxproj b/Cryptomator.xcodeproj/project.pbxproj index 69493c602..7244fec5e 100644 --- a/Cryptomator.xcodeproj/project.pbxproj +++ b/Cryptomator.xcodeproj/project.pbxproj @@ -290,8 +290,6 @@ 4ABCF3522726D24800A7FBB7 /* MoveVaultViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ABCF3512726D24800A7FBB7 /* MoveVaultViewModelTests.swift */; }; 4AC005F127C3D80B006FFE87 /* PremiumManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AC005F027C3D80B006FFE87 /* PremiumManager.swift */; }; 4AC005F327C3D932006FFE87 /* PremiumManagerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AC005F227C3D932006FFE87 /* PremiumManagerMock.swift */; }; - 4AC1157627F5BD890023F51B /* Promise+AllIgnoringResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AC1157527F5BD890023F51B /* Promise+AllIgnoringResult.swift */; }; - 4AC1157827F5BEFD0023F51B /* Promise+AllIgnoringResultsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AC1157727F5BEFD0023F51B /* Promise+AllIgnoringResultsTests.swift */; }; 4AC86270273598CC00E15BA5 /* UIViewController+ProgressHUDError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AC8626F273598CC00E15BA5 /* UIViewController+ProgressHUDError.swift */; }; 4AD0F61C24AF203F0026B765 /* FileProvider+Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AD0F61B24AF203F0026B765 /* FileProvider+Actions.swift */; }; 4AD3D7D6282EBDE7008188CD /* Intents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AD3D7D5282EBDE7008188CD /* Intents.framework */; }; @@ -828,8 +826,6 @@ 4ABCF3512726D24800A7FBB7 /* MoveVaultViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoveVaultViewModelTests.swift; sourceTree = ""; }; 4AC005F027C3D80B006FFE87 /* PremiumManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PremiumManager.swift; sourceTree = ""; }; 4AC005F227C3D932006FFE87 /* PremiumManagerMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PremiumManagerMock.swift; sourceTree = ""; }; - 4AC1157527F5BD890023F51B /* Promise+AllIgnoringResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Promise+AllIgnoringResult.swift"; sourceTree = ""; }; - 4AC1157727F5BEFD0023F51B /* Promise+AllIgnoringResultsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Promise+AllIgnoringResultsTests.swift"; sourceTree = ""; }; 4AC8626F273598CC00E15BA5 /* UIViewController+ProgressHUDError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+ProgressHUDError.swift"; sourceTree = ""; }; 4AD0F61B24AF203F0026B765 /* FileProvider+Actions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileProvider+Actions.swift"; sourceTree = ""; }; 4AD3D7D4282EBDE7008188CD /* CryptomatorIntents.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = CryptomatorIntents.appex; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1214,7 +1210,6 @@ 4AFBFA19282946BF00E30818 /* InMemoryProgressManagerTests.swift */, 4AB1D4EF27D20420009060AB /* LocalURLProviderTests.swift */, 4A0AA12C2ABA277800CF24FD /* PermissionProviderImplTests.swift */, - 4AC1157727F5BEFD0023F51B /* Promise+AllIgnoringResultsTests.swift */, 4ADC66C427A7F6D6002E6CC7 /* UnlockMonitorTests.swift */, 4A4F47F224B875070033328B /* URL+NameCollisionExtensionTests.swift */, 4AE5196427F48D6600BA6E4A /* WorkflowDependencyFactoryTests.swift */, @@ -1926,7 +1921,6 @@ 4AEE6EE02822A33400E1B35E /* NSFileProviderItemIdentifier+Database.swift */, 4A0AA12A2AB8DB1800CF24FD /* PermissionProvider.swift */, 4AEE6EE92825716400E1B35E /* ProgressManager.swift */, - 4AC1157527F5BD890023F51B /* Promise+AllIgnoringResult.swift */, 4ADD233F26737CD400374E4E /* RootFileProviderItem.swift */, 4A7514A02937F777002E802E /* SessionTaskRegistrator.swift */, 4ADC66C027A7F426002E6CC7 /* UnlockMonitor.swift */, @@ -2572,7 +2566,6 @@ 4AB1C33C265E9DBC00DC7A49 /* CloudTaskExecutorTestCase.swift in Sources */, 4AE5196727F495BF00BA6E4A /* WorkflowDependencyTasksCollectionMock.swift in Sources */, 4A0AA12F2ABA2A1600CF24FD /* PermissionProviderMock.swift in Sources */, - 4AC1157827F5BEFD0023F51B /* Promise+AllIgnoringResultsTests.swift in Sources */, 4AE5196527F48D6600BA6E4A /* WorkflowDependencyFactoryTests.swift in Sources */, 4A49FABE271ECDE80069A0CC /* ItemEnumerationTaskManagerTests.swift in Sources */, 4A248229266E2DD6002D9F59 /* FileProviderAdapterCreateDirectoryTests.swift in Sources */, @@ -2955,7 +2948,6 @@ 4ADD234026737CD400374E4E /* RootFileProviderItem.swift in Sources */, 747F2F232587BC250072FB30 /* ItemMetadataDBManager.swift in Sources */, 4A511D47265FEFBE000A0E01 /* DownloadTask.swift in Sources */, - 4AC1157627F5BD890023F51B /* Promise+AllIgnoringResult.swift in Sources */, 4A09E54E27071F4F0056D32A /* ErrorMapper.swift in Sources */, 4AEECD35279EB0FD00C6E2B5 /* FileProviderEnumerator.swift in Sources */, 4AE0D8DC2653DF1300DF5D22 /* DownloadTaskExecutor.swift in Sources */, diff --git a/Cryptomator/VaultList/VaultListViewModel.swift b/Cryptomator/VaultList/VaultListViewModel.swift index 5883e141e..1a986044e 100644 --- a/Cryptomator/VaultList/VaultListViewModel.swift +++ b/Cryptomator/VaultList/VaultListViewModel.swift @@ -107,10 +107,7 @@ class VaultListViewModel: ViewModel, VaultListViewModelProtocol { let promises = vaultCellViewModels.map { vaultCellViewModel in return checkVaultUnlockStatus(for: vaultCellViewModel.vault) } - - return all(promises).then {_ in - print("All vault lock states refreshed.") - } + return all(ignoringResult: promises) } private func checkVaultUnlockStatus(for vault: VaultInfo) -> Promise { diff --git a/CryptomatorFileProvider/Promise+AllIgnoringResult.swift b/CryptomatorCommon/Sources/CryptomatorCommonCore/Promise+AllIgnoringResult.swift similarity index 69% rename from CryptomatorFileProvider/Promise+AllIgnoringResult.swift rename to CryptomatorCommon/Sources/CryptomatorCommonCore/Promise+AllIgnoringResult.swift index 057ba025a..d16ca1db6 100644 --- a/CryptomatorFileProvider/Promise+AllIgnoringResult.swift +++ b/CryptomatorCommon/Sources/CryptomatorCommonCore/Promise+AllIgnoringResult.swift @@ -9,7 +9,7 @@ import Foundation import Promises -func all(ignoringResult promises: Container) -> Promise where Container.Element == Promise { +public func all(ignoringResult promises: Container) -> Promise where Container.Element == Promise { return any(promises).then { _ -> Void in // discard result }.recover { _ -> Void in diff --git a/CryptomatorFileProviderTests/Promise+AllIgnoringResultsTests.swift b/CryptomatorCommon/Tests/CryptomatorCommonCoreTests/Promise+AllIgnoringResultsTests.swift similarity index 92% rename from CryptomatorFileProviderTests/Promise+AllIgnoringResultsTests.swift rename to CryptomatorCommon/Tests/CryptomatorCommonCoreTests/Promise+AllIgnoringResultsTests.swift index df9833f9a..106e5b744 100644 --- a/CryptomatorFileProviderTests/Promise+AllIgnoringResultsTests.swift +++ b/CryptomatorCommon/Tests/CryptomatorCommonCoreTests/Promise+AllIgnoringResultsTests.swift @@ -1,14 +1,14 @@ // // Promise+AllIgnoringResultsTests.swift -// CryptomatorFileProviderTests +// CryptomatorCommonCoreTests // // Created by Philipp Schmid on 31.03.22. // Copyright © 2022 Skymatic GmbH. All rights reserved. // +import CryptomatorCommonCore import Promises import XCTest -@testable import CryptomatorFileProvider class Promise_AllIgnoringResultsTests: XCTestCase { func testWaitForAll() throws { diff --git a/CryptomatorCommon/Tests/CryptomatorCommonCoreTests/XCTestCase+Promises.swift b/CryptomatorCommon/Tests/CryptomatorCommonCoreTests/XCTestCase+Promises.swift index 938c35b74..ef9ccdcd8 100644 --- a/CryptomatorCommon/Tests/CryptomatorCommonCoreTests/XCTestCase+Promises.swift +++ b/CryptomatorCommon/Tests/CryptomatorCommonCoreTests/XCTestCase+Promises.swift @@ -37,4 +37,13 @@ extension XCTestCase { } wait(for: [expectation], timeout: 1.0) } + + func XCTAssertGetsNotExecuted(_ promise: Promise, timeout seconds: TimeInterval = 1.0, file: StaticString = #filePath, line: UInt = #line) { + let expectation = XCTestExpectation() + expectation.isInverted = true + promise.always { + expectation.fulfill() + } + wait(for: [expectation], timeout: seconds) + } } diff --git a/CryptomatorFileProvider/Workflow/WorkflowDependencyFactory.swift b/CryptomatorFileProvider/Workflow/WorkflowDependencyFactory.swift index c35c7f311..9aa0d2fb0 100644 --- a/CryptomatorFileProvider/Workflow/WorkflowDependencyFactory.swift +++ b/CryptomatorFileProvider/Workflow/WorkflowDependencyFactory.swift @@ -8,6 +8,7 @@ import CocoaLumberjackSwift import CryptomatorCloudAccessCore +import CryptomatorCommonCore import Foundation import Promises