mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-16 12:00:03 +03:00
Do not propose to verify the current session if there is only one session (#1901)
This commit is contained in:
parent
96c7f57ea0
commit
2efe5a420c
4 changed files with 21 additions and 8 deletions
|
@ -7,6 +7,7 @@ Features ✨:
|
|||
Improvements 🙌:
|
||||
- You can now join room through permalink and within room directory search
|
||||
- Add long click gesture to copy userId, user display name, room name, room topic and room alias (#1774)
|
||||
- Do not propose to verify session if there is only one session (#1901)
|
||||
|
||||
Bugfix 🐛:
|
||||
- Display name not shown under Settings/General (#1926)
|
||||
|
|
|
@ -66,16 +66,18 @@ class DeviceVerificationInfoBottomSheetController @Inject constructor(
|
|||
|
||||
if (data.hasAccountCrossSigning) {
|
||||
// Cross Signing is enabled
|
||||
handleE2EWithCrossSigning(data.isMine, data.accountCrossSigningIsTrusted, cryptoDeviceInfo, shield)
|
||||
handleE2EWithCrossSigning(data, cryptoDeviceInfo, shield)
|
||||
} else {
|
||||
handleE2EInLegacy(data.isMine, cryptoDeviceInfo, shield)
|
||||
handleE2EInLegacy(data, cryptoDeviceInfo, shield)
|
||||
}
|
||||
|
||||
// COMMON ACTIONS (Rename / signout)
|
||||
addGenericDeviceManageActions(data, cryptoDeviceInfo.deviceId)
|
||||
}
|
||||
|
||||
private fun handleE2EWithCrossSigning(isMine: Boolean, currentSessionIsTrusted: Boolean, cryptoDeviceInfo: CryptoDeviceInfo, shield: Int) {
|
||||
private fun handleE2EWithCrossSigning(data: DeviceVerificationInfoBottomSheetViewState, cryptoDeviceInfo: CryptoDeviceInfo, shield: Int) {
|
||||
val isMine = data.isMine
|
||||
val currentSessionIsTrusted = data.accountCrossSigningIsTrusted
|
||||
Timber.v("handleE2EWithCrossSigning $isMine, $cryptoDeviceInfo, $shield")
|
||||
|
||||
if (isMine) {
|
||||
|
@ -87,8 +89,8 @@ class DeviceVerificationInfoBottomSheetController @Inject constructor(
|
|||
title(stringProvider.getString(R.string.encryption_information_verified))
|
||||
description(stringProvider.getString(R.string.settings_active_sessions_verified_device_desc))
|
||||
}
|
||||
} else {
|
||||
// You need to complete security
|
||||
} else if (data.hasOtherSessions) {
|
||||
// You need to complete security, only if there are other session(s) available
|
||||
genericItem {
|
||||
id("trust${cryptoDeviceInfo.deviceId}")
|
||||
style(GenericItem.STYLE.BIG_TEXT)
|
||||
|
@ -131,7 +133,7 @@ class DeviceVerificationInfoBottomSheetController @Inject constructor(
|
|||
description("(${cryptoDeviceInfo.deviceId})")
|
||||
}
|
||||
|
||||
if (isMine && !currentSessionIsTrusted) {
|
||||
if (isMine && !currentSessionIsTrusted && data.hasOtherSessions) {
|
||||
// Add complete security
|
||||
dividerItem {
|
||||
id("completeSecurityDiv")
|
||||
|
@ -157,8 +159,9 @@ class DeviceVerificationInfoBottomSheetController @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleE2EInLegacy(isMine: Boolean, cryptoDeviceInfo: CryptoDeviceInfo, shield: Int) {
|
||||
private fun handleE2EInLegacy(data: DeviceVerificationInfoBottomSheetViewState, cryptoDeviceInfo: CryptoDeviceInfo, shield: Int) {
|
||||
// ==== Legacy
|
||||
val isMine = data.isMine
|
||||
|
||||
// TRUST INFO SECTION
|
||||
if (cryptoDeviceInfo.trustLevel?.isLocallyVerified() == true) {
|
||||
|
|
|
@ -65,6 +65,14 @@ class DeviceVerificationInfoBottomSheetViewModel @AssistedInject constructor(@As
|
|||
)
|
||||
}
|
||||
|
||||
session.rx().liveUserCryptoDevices(session.myUserId)
|
||||
.map { it.size }
|
||||
.execute {
|
||||
copy(
|
||||
hasOtherSessions = it.invoke() ?: 0 > 1
|
||||
)
|
||||
}
|
||||
|
||||
setState {
|
||||
copy(deviceInfo = Loading())
|
||||
}
|
||||
|
|
|
@ -27,5 +27,6 @@ data class DeviceVerificationInfoBottomSheetViewState(
|
|||
val deviceInfo: Async<DeviceInfo> = Uninitialized,
|
||||
val hasAccountCrossSigning: Boolean = false,
|
||||
val accountCrossSigningIsTrusted: Boolean = false,
|
||||
val isMine: Boolean = false
|
||||
val isMine: Boolean = false,
|
||||
val hasOtherSessions: Boolean = false
|
||||
) : MvRxState
|
||||
|
|
Loading…
Add table
Reference in a new issue