Skip to content

Commit

Permalink
Refactored refreshVaultLockStates()
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Oct 16, 2024
1 parent 99a0e0c commit 889984d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
8 changes: 0 additions & 8 deletions Cryptomator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -828,8 +826,6 @@
4ABCF3512726D24800A7FBB7 /* MoveVaultViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoveVaultViewModelTests.swift; sourceTree = "<group>"; };
4AC005F027C3D80B006FFE87 /* PremiumManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PremiumManager.swift; sourceTree = "<group>"; };
4AC005F227C3D932006FFE87 /* PremiumManagerMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PremiumManagerMock.swift; sourceTree = "<group>"; };
4AC1157527F5BD890023F51B /* Promise+AllIgnoringResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Promise+AllIgnoringResult.swift"; sourceTree = "<group>"; };
4AC1157727F5BEFD0023F51B /* Promise+AllIgnoringResultsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Promise+AllIgnoringResultsTests.swift"; sourceTree = "<group>"; };
4AC8626F273598CC00E15BA5 /* UIViewController+ProgressHUDError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+ProgressHUDError.swift"; sourceTree = "<group>"; };
4AD0F61B24AF203F0026B765 /* FileProvider+Actions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileProvider+Actions.swift"; sourceTree = "<group>"; };
4AD3D7D4282EBDE7008188CD /* CryptomatorIntents.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = CryptomatorIntents.appex; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
5 changes: 1 addition & 4 deletions Cryptomator/VaultList/VaultListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import Promises

func all<Value, Container: Sequence>(ignoringResult promises: Container) -> Promise<Void> where Container.Element == Promise<Value> {
public func all<Value, Container: Sequence>(ignoringResult promises: Container) -> Promise<Void> where Container.Element == Promise<Value> {
return any(promises).then { _ -> Void in
// discard result
}.recover { _ -> Void in
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@ extension XCTestCase {
}
wait(for: [expectation], timeout: 1.0)
}

func XCTAssertGetsNotExecuted<T>(_ promise: Promise<T>, 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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import CocoaLumberjackSwift
import CryptomatorCloudAccessCore
import CryptomatorCommonCore
import Foundation
import Promises

Expand Down

0 comments on commit 889984d

Please sign in to comment.