Skip to content

Commit

Permalink
Refactor ifs into a match
Browse files Browse the repository at this point in the history
Co-authored-by: Damir Jelić <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
  • Loading branch information
andybalaam and poljar authored Dec 12, 2024
1 parent ebbde1a commit ffe7486
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions crates/matrix-sdk-crypto/src/types/events/utd_cause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,19 @@ impl UtdCause {
* ```
*/
fn determine_historical(crypto_context_info: CryptoContextInfo) -> UtdCause {
if crypto_context_info.backup_exists_on_server {
if crypto_context_info.is_backup_configured
|| crypto_context_info.this_device_is_verified
{
let backup_exist = crypto_context_info.backup_exists_on_server;
let is_backup_configured = crypto_context_info.is_backup_configured;
let are_we_verified = crypto_context_info.this_device_is_verified;

match (backup_exist, is_backup_configured || are_we_verified) {
(true, true) => {
// Either backup download is working but we still don't have the key, or backup
// download *isn't* working despite being verified. In either
// case, we shrug and give an `Unknown` cause.
UtdCause::Unknown
} else {
UtdCause::HistoricalMessageAndDeviceIsUnverified
}
} else {
UtdCause::HistoricalMessageAndBackupIsDisabled
(true, false) => UtdCause::HistoricalMessageAndDeviceIsUnverified,
(false, _) => UtdCause::HistoricalMessageAndBackupIsDisabled,
}
}
}
Expand Down

0 comments on commit ffe7486

Please sign in to comment.