Skip to content

Commit

Permalink
fix(e2ei): set user display name correctly for the certificate downlo…
Browse files Browse the repository at this point in the history
…aded file
  • Loading branch information
mchenani committed Apr 26, 2024
1 parent 413a82b commit 8c1b254
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/src/main/kotlin/com/wire/android/ui/WireActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class WireActivity : AppCompatActivity() {
result = e2EIResult,
updateCertificate = featureFlagNotificationViewModel::enrollE2EICertificate,
snoozeDialog = featureFlagNotificationViewModel::snoozeE2EIdRequiredDialog,
openCertificateDetails = { navigate(NavigationCommand(E2eiCertificateDetailsScreenDestination(it))) },
openCertificateDetails = { navigate(NavigationCommand(E2eiCertificateDetailsScreenDestination(it, true))) },
dismissSuccessDialog = featureFlagNotificationViewModel::dismissSuccessE2EIdDialog,
isE2EILoading = isE2EILoading
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fun E2EIEnrollmentScreen(
enrollE2EICertificate = viewModel::enrollE2EICertificate,
handleE2EIEnrollmentResult = viewModel::handleE2EIEnrollmentResult,
openCertificateDetails = {
navigator.navigate(NavigationCommand(E2eiCertificateDetailsScreenDestination(state.certificate)))
navigator.navigate(NavigationCommand(E2eiCertificateDetailsScreenDestination(state.certificate, true)))
},
onBackButtonClicked = viewModel::onBackButtonClicked,
onCancelEnrollmentClicked = { viewModel.onCancelEnrollmentClicked(NavigationSwitchAccountActions(navigator::navigate)) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireDimensions
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.CustomTabsHelper
import com.wire.android.util.deviceDateTimeFormat
import com.wire.android.util.dialogErrorStrings
import com.wire.android.util.extension.formatAsFingerPrint
import com.wire.android.util.extension.formatAsString
import com.wire.android.util.deviceDateTimeFormat
import com.wire.android.util.ui.UIText
import com.wire.kalium.logic.CoreFailure
import com.wire.kalium.logic.data.conversation.ClientId
Expand Down Expand Up @@ -117,7 +117,9 @@ fun DeviceDetailsScreen(
handleE2EIEnrollmentResult = viewModel::handleE2EIEnrollmentResult,
onNavigateToE2eiCertificateDetailsScreen = {
navigator.navigate(
NavigationCommand(E2eiCertificateDetailsScreenDestination(it))
NavigationCommand(
E2eiCertificateDetailsScreenDestination(it, viewModel.state.isSelfClient, viewModel.state.userName)
)
)
},
onEnrollE2EIErrorDismiss = viewModel::hideEnrollE2EICertificateError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
package com.wire.android.ui.settings.devices.e2ei

data class E2eiCertificateDetailsScreenNavArgs(
val certificateString: String
val certificateString: String,
val isSelfUser: Boolean,
val otherUserName: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,24 @@ class E2eiCertificateDetailsViewModel @Inject constructor(
private val e2eiCertificateDetailsScreenNavArgs: E2eiCertificateDetailsScreenNavArgs =
savedStateHandle.navArgs()

private var selfUserHandle: String? = null
private var selfUserName: String? = null

init {
getSelfUserId()
}

private fun getSelfUserId() {
viewModelScope.launch {
selfUserHandle = observerSelfUser().first().handle
selfUserName = observerSelfUser().first().name
}
}

fun getCertificate() = e2eiCertificateDetailsScreenNavArgs.certificateString

fun getCertificateName(): String {
val date = DateTimeUtil.currentInstant().fileDateTime()
return "wire-certificate-$selfUserHandle-$date.txt"
val userName = if(e2eiCertificateDetailsScreenNavArgs.isSelfUser) selfUserName else e2eiCertificateDetailsScreenNavArgs.otherUserName
return "wire-certificate-$userName-$date.txt"
}
}

Expand Down

0 comments on commit 8c1b254

Please sign in to comment.