Skip to content

Commit

Permalink
Fix logic
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaresiak committed Apr 15, 2024
1 parent e0386be commit f023a1f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ public class SyncSettingsViewModel: ObservableObject {
}

func saveRecoveryPDF() {
delegate?.shareRecoveryPDF()
Task { @MainActor in
if await commonAuthenticate() {
delegate?.shareRecoveryPDF()
}
}
}

func scanQRCode() {
Expand Down Expand Up @@ -214,6 +218,10 @@ public class SyncSettingsViewModel: ObservableObject {
}

public func recoverSyncDataPressed() {
delegate?.showRecoverData()
Task { @MainActor in
if await commonAuthenticate() {
delegate?.showRecoverData()
}
}
}
}
12 changes: 12 additions & 0 deletions LocalPackages/SyncUI/Sources/SyncUI/Views/SyncSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ public struct SyncSettingsView: View {
.navigationTitle(UserText.syncTitle)
.applyListStyle()
.environmentObject(model)
.alert(isPresented: $model.shouldShowPasscodeRequiredAlert) {
Alert(
title: Text("Secure Your Device to Use Sync & Backup"),
message: Text("A device password is required to use Sync & Backup."),
dismissButton: .default(Text("Go to Settings"), action: {
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!,
options: [:],
completionHandler: nil)
model.shouldShowPasscodeRequiredAlert = false
})
)
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ extension SyncSettingsView {

@ViewBuilder
func otherOptions() -> some View {
let alertBinding = Binding<Bool>(
get: { model.shouldShowPasscodeRequiredAlert },
set: { value in model.shouldShowPasscodeRequiredAlert = value }
)

Section {
Button(UserText.syncAndBackUpThisDeviceLink) {
Task { @MainActor in
Expand Down Expand Up @@ -107,18 +102,6 @@ extension SyncSettingsView {
})
})
.disabled(!model.isAccountRecoveryAvailable)
.alert(isPresented: alertBinding) {
Alert(
title: Text("Secure Your Device to Use Sync & Backup"),
message: Text("A device password is required to use Sync & Backup."),
dismissButton: .default(Text("Go to Settings"), action: {
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!,
options: [:],
completionHandler: nil)
model.shouldShowPasscodeRequiredAlert = false
})
)
}

} header: {
Text(UserText.otherOptionsSectionHeader)
Expand Down

0 comments on commit f023a1f

Please sign in to comment.