Skip to content

Commit

Permalink
Merge pull request #176 from ministero-salute/feature/work-scan-mode-…
Browse files Browse the repository at this point in the history
…disabled

feat: work scan mode disabled
  • Loading branch information
astagi authored Mar 28, 2022
2 parents 76c10b1 + 0fff743 commit e572de1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions DGCAVerifier/Pages/Home/HomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ class HomeViewModel {
public func startOperations() {
isLoading.value = true
GatewayConnection.shared.initialize { [weak self] in self?.load() }
self.handleWorkScanModePreference()
}

/// Removes the `.work` scanMode preference if previously set.
private func handleWorkScanModePreference() -> Void {
guard let scanMode: ScanMode = ScanMode.fetchFromLocalSettings() else { return }

if scanMode == .work {
Store.remove(key: Store.Key.scanMode)
Store.set(false, for: .isScanModeSet)
}
}

public func loadComplete(updateLastFetch: Bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class CustomPickerController: UIViewController {

private func setupPickerOptionContents() -> Void {
ScanMode.allCases.forEach{
guard $0 != .work else { return }

self.optionContents.append(.init(
scanMode: $0,
scanModeName: $0.buttonTitleName,
Expand Down Expand Up @@ -164,6 +166,10 @@ class CustomPickerController: UIViewController {
return
}

// If, for some reason, the user managed to get to this point attempting to select the `.work` scan mode,
// exit early.
guard selectedScanMode != .work else { return }

Store.set(selectedScanMode.rawValue, for: .scanMode)
Store.set(true, for: .isScanModeSet)

Expand Down

0 comments on commit e572de1

Please sign in to comment.