Skip to content

Commit

Permalink
update copies and address PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
cmonfortep committed Nov 19, 2024
1 parent 7b034f7 commit 7ab217c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class AppSyncAccountRepository @Inject constructor(

private fun login(recoveryCode: RecoveryCode): Result<Boolean> {
if (isSignedIn()) {
return Error(code = ALREADY_SIGNED_IN.code, reason = "Already signed in", payload = recoveryCode)
return Error(code = ALREADY_SIGNED_IN.code, reason = "Already signed in")
.alsoFireAlreadySignedInErrorPixel()
}

Expand Down Expand Up @@ -324,10 +324,11 @@ class AppSyncAccountRepository @Inject constructor(
override fun isSignedIn() = syncStore.isSignedIn()

override fun logoutAndJoinNewAccount(stringCode: String): Result<Boolean> {
logout(syncStore.deviceId.orEmpty()).takeIf { it is Error }?.let {
return it
val thisDeviceId = syncStore.deviceId.orEmpty()
return when (val result = logout(thisDeviceId)) {
is Error -> result
is Result.Success -> processCode(stringCode)
}
return processCode(stringCode)
}

private fun performCreateAccount(): Result<Boolean> {
Expand Down Expand Up @@ -562,7 +563,6 @@ sealed class Result<out R> {
data class Error(
val code: Int = GENERIC_ERROR.code,
val reason: String = "",
val payload: Any? = null,
) : Result<Nothing>()

override fun toString(): String {
Expand Down
5 changes: 3 additions & 2 deletions sync/sync-impl/src/main/res/values/donottranslate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
<string name="deviceIdSectionHeader">Device Id</string>
<string name="deviceNameSectionHeader">Device Name</string>

<string name="sync_dialog_switch_account_primary_button">Switch Account</string>
<string name="sync_dialog_switch_account_header">This device is already synced.</string>
<string name="sync_dialog_switch_account_primary_button">Switch Sync</string>
<string name="sync_dialog_switch_account_secondary_button">Cancel</string>
<string name="sync_dialog_switch_account_description">"You\'re already signed in to another account. Would you like to sign out and switch accounts?"</string>
<string name="sync_dialog_switch_account_description">This device is currently synced and backed up. Are you sure you want to sync it with a different backup or device?\nSwitching won\'t remove any data already synced to this device.</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class SyncWithAnotherDeviceViewModelTest {
}

@Test
fun whenUserScansRecoveryCodeButSignedInThenCommandIsAskToSwithAccount() = runTest {
fun whenUserScansRecoveryCodeButSignedInThenCommandIsAskToSwitchAccount() = runTest {
whenever(syncRepository.processCode(jsonRecoveryKeyEncoded)).thenReturn(Result.Error(code = ALREADY_SIGNED_IN.code))
testee.commands().test {
testee.onQRCodeScanned(jsonRecoveryKeyEncoded)
Expand Down

0 comments on commit 7ab217c

Please sign in to comment.