Skip to content

Commit

Permalink
Merge branch 'release/1.124.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
graeme committed Jan 29, 2025
2 parents 9da2de4 + a849c69 commit db394d8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Configuration/BuildNumber.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 351
CURRENT_PROJECT_VERSION = 352
12 changes: 6 additions & 6 deletions DuckDuckGo/Preferences/Model/SyncPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -771,16 +771,16 @@ extension SyncPreferences: ManagementDialogModelDelegate {
}

private func handleAccountAlreadyExists(_ recoveryKey: SyncCode.RecoveryKey) {
if devices.count > 1 {
managementDialogModel.shouldShowSwitchAccountsMessage = true
PixelKit.fire(SyncSwitchAccountPixelKitEvent.syncAskUserToSwitchAccount.withoutMacPrefix)
} else {
Task { @MainActor in
Task { @MainActor in
if devices.count > 1 {
managementDialogModel.showSwitchAccountsMessage()
PixelKit.fire(SyncSwitchAccountPixelKitEvent.syncAskUserToSwitchAccount.withoutMacPrefix)
} else {
await switchAccounts(recoveryKey: recoveryKey)
managementDialogModel.endFlow()
}
PixelKit.fire(DebugEvent(GeneralPixel.syncLoginExistingAccountError(error: SyncError.accountAlreadyExists)))
}
PixelKit.fire(DebugEvent(GeneralPixel.syncLoginExistingAccountError(error: SyncError.accountAlreadyExists)))
}

func userConfirmedSwitchAccounts(recoveryCode: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public final class ManagementDialogModel: ObservableObject {
.sink { [weak self] hasError in
self?.shouldShowErrorMessage = hasError
}

}

@MainActor
Expand All @@ -72,6 +73,12 @@ public final class ManagementDialogModel: ObservableObject {
delegate?.userConfirmedSwitchAccounts(recoveryCode: recoveryCode)
}

@MainActor
public func showSwitchAccountsMessage() {
shouldShowSwitchAccountsMessage = true
shouldShowErrorMessage = true
}

@MainActor
private func doEndFlow() {
syncErrorMessage?.type.onButtonPressed(delegate: delegate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,26 @@ public struct ManagementDialog: View {
public var body: some View {
content
.alert(isPresented: $model.shouldShowErrorMessage) {
Alert(
title: Text(errorTitle),
message: Text(errorDescription),
dismissButton: .default(Text(buttonTitle)) {
model.endFlow()
}
)
}
.alert(isPresented: $model.shouldShowSwitchAccountsMessage) {
Alert(
title: Text(UserText.syncAlertSwitchAccountTitle),
message: Text(UserText.syncAlertSwitchAccountMessage),
primaryButton: .default(Text(UserText.syncAlertSwitchAccountButton)) {
model.userConfirmedSwitchAccounts(recoveryCode: recoveryCodeModel.recoveryCode)
},
secondaryButton: .cancel {
model.endFlow()
}
)
if model.shouldShowSwitchAccountsMessage {
Alert(
title: Text(UserText.syncAlertSwitchAccountTitle),
message: Text(UserText.syncAlertSwitchAccountMessage),
primaryButton: .default(Text(UserText.syncAlertSwitchAccountButton)) {
model.userConfirmedSwitchAccounts(recoveryCode: recoveryCodeModel.recoveryCode)
},
secondaryButton: .cancel {
model.endFlow()
}
)
} else {
Alert(
title: Text(errorTitle),
message: Text(errorDescription),
dismissButton: .default(Text(buttonTitle)) {
model.endFlow()
}
)
}
}
}

Expand Down
1 change: 1 addition & 0 deletions UnitTests/Sync/SyncPreferencesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ final class SyncPreferencesTests: XCTestCase {

await fulfillment(of: [loginCalledExpectation], timeout: 5.0)

XCTAssert(managementDialogModel.shouldShowErrorMessage)
XCTAssert(managementDialogModel.shouldShowSwitchAccountsMessage)
}

Expand Down

0 comments on commit db394d8

Please sign in to comment.