This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 831
Improve usability of the decryption banner #11012
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5e0ac54
Display `Open another device` only when `developerMode` is enabled
florianduros 87e6c3e
Move `Resend key requests` into `Open another device`
florianduros 7704e35
Remove reset keys and unable to decrypt banners.
florianduros f9a9107
Replace `Decrypting messages…` wording
florianduros b0175b8
Move resend key request in generic decryption error
florianduros 1ce2c34
Update `DecryptionFailureBare-test.tsx`
florianduros 87cbba4
Remove old snapshot
florianduros a3b83c1
Reduce banner font
florianduros 7fe2c11
Update cypress test
florianduros File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -20,14 +20,11 @@ import { CryptoEvent } from "matrix-js-sdk/src/crypto"; | |||||||||
|
||||||||||
import Modal from "../../../Modal"; | ||||||||||
import { _t } from "../../../languageHandler"; | ||||||||||
import defaultDispatcher from "../../../dispatcher/dispatcher"; | ||||||||||
import { Action } from "../../../dispatcher/actions"; | ||||||||||
import AccessibleButton from "../elements/AccessibleButton"; | ||||||||||
import { OpenToTabPayload } from "../../../dispatcher/payloads/OpenToTabPayload"; | ||||||||||
import MatrixClientContext from "../../../contexts/MatrixClientContext"; | ||||||||||
import SetupEncryptionDialog from "../dialogs/security/SetupEncryptionDialog"; | ||||||||||
import { SetupEncryptionStore } from "../../../stores/SetupEncryptionStore"; | ||||||||||
import Spinner from "../elements/Spinner"; | ||||||||||
import { useSettingValue } from "../../../hooks/useSettings"; | ||||||||||
|
||||||||||
interface IProps { | ||||||||||
failures: MatrixEvent[]; | ||||||||||
|
@@ -38,6 +35,7 @@ const WAIT_PERIOD = 5000; | |||||||||
|
||||||||||
export const DecryptionFailureBar: React.FC<IProps> = ({ failures }) => { | ||||||||||
const context = useContext(MatrixClientContext); | ||||||||||
const developerMode = useSettingValue<boolean>("developerMode"); | ||||||||||
|
||||||||||
// Display a spinner for a few seconds before presenting an error message, | ||||||||||
// in case keys are about to arrive | ||||||||||
|
@@ -134,16 +132,6 @@ export const DecryptionFailureBar: React.FC<IProps> = ({ failures }) => { | |||||||||
Modal.createDialog(SetupEncryptionDialog); | ||||||||||
}; | ||||||||||
|
||||||||||
const onDeviceListClick = (): void => { | ||||||||||
const payload: OpenToTabPayload = { action: Action.ViewUserDeviceSettings }; | ||||||||||
defaultDispatcher.dispatch(payload); | ||||||||||
}; | ||||||||||
|
||||||||||
const onResetClick = (): void => { | ||||||||||
const store = SetupEncryptionStore.sharedInstance(); | ||||||||||
store.resetConfirm(); | ||||||||||
}; | ||||||||||
|
||||||||||
const statusIndicator = waiting ? ( | ||||||||||
<Spinner w={24} h={24} /> | ||||||||||
) : ( | ||||||||||
|
@@ -154,78 +142,38 @@ export const DecryptionFailureBar: React.FC<IProps> = ({ failures }) => { | |||||||||
let headline: JSX.Element; | ||||||||||
let message: JSX.Element; | ||||||||||
let button = <React.Fragment />; | ||||||||||
let keyRequestButton = <React.Fragment />; | ||||||||||
if (waiting) { | ||||||||||
className = "mx_DecryptionFailureBar"; | ||||||||||
headline = <React.Fragment>{_t("Decrypting messages…")}</React.Fragment>; | ||||||||||
message = ( | ||||||||||
<React.Fragment> | ||||||||||
{_t("Please wait as we try to decrypt your messages. This may take a few moments.")} | ||||||||||
{_t( | ||||||||||
"Please wait while your messages are decrypted. This may take a few moments. Opening Element on another device can speed this up.", | ||||||||||
)} | ||||||||||
</React.Fragment> | ||||||||||
); | ||||||||||
} else if (needsVerification) { | ||||||||||
if (hasOtherVerifiedDevices || hasKeyBackup) { | ||||||||||
className = "mx_DecryptionFailureBar mx_DecryptionFailureBar--withEnd"; | ||||||||||
headline = <React.Fragment>{_t("Verify this device to access all messages")}</React.Fragment>; | ||||||||||
message = ( | ||||||||||
<React.Fragment> | ||||||||||
{_t("This device was unable to decrypt some messages because it has not been verified yet.")} | ||||||||||
</React.Fragment> | ||||||||||
); | ||||||||||
button = ( | ||||||||||
<AccessibleButton | ||||||||||
className="mx_DecryptionFailureBar_end_button" | ||||||||||
kind="primary" | ||||||||||
onClick={onVerifyClick} | ||||||||||
data-testid="decryption-failure-bar-button" | ||||||||||
> | ||||||||||
{_t("Verify")} | ||||||||||
</AccessibleButton> | ||||||||||
); | ||||||||||
} else { | ||||||||||
className = "mx_DecryptionFailureBar mx_DecryptionFailureBar--withEnd"; | ||||||||||
headline = <React.Fragment>{_t("Reset your keys to prevent future decryption errors")}</React.Fragment>; | ||||||||||
message = ( | ||||||||||
<React.Fragment> | ||||||||||
{_t( | ||||||||||
"You will not be able to access old undecryptable messages, " + | ||||||||||
"but resetting your keys will allow you to receive new messages.", | ||||||||||
)} | ||||||||||
</React.Fragment> | ||||||||||
); | ||||||||||
button = ( | ||||||||||
<AccessibleButton | ||||||||||
className="mx_DecryptionFailureBar_end_button" | ||||||||||
kind="primary" | ||||||||||
onClick={onResetClick} | ||||||||||
data-testid="decryption-failure-bar-button" | ||||||||||
> | ||||||||||
{_t("Reset")} | ||||||||||
</AccessibleButton> | ||||||||||
); | ||||||||||
} | ||||||||||
} else if (hasOtherVerifiedDevices) { | ||||||||||
} else if (needsVerification && (hasOtherVerifiedDevices || hasKeyBackup)) { | ||||||||||
className = "mx_DecryptionFailureBar mx_DecryptionFailureBar--withEnd"; | ||||||||||
headline = <React.Fragment>{_t("Open another device to load encrypted messages")}</React.Fragment>; | ||||||||||
headline = <React.Fragment>{_t("Verify this device to access all messages")}</React.Fragment>; | ||||||||||
message = ( | ||||||||||
<React.Fragment> | ||||||||||
{_t( | ||||||||||
"This device is requesting decryption keys from your other devices. " + | ||||||||||
"Opening one of your other devices may speed this up.", | ||||||||||
)} | ||||||||||
{_t("This device was unable to decrypt some messages because it has not been verified yet.")} | ||||||||||
</React.Fragment> | ||||||||||
); | ||||||||||
button = ( | ||||||||||
<AccessibleButton | ||||||||||
className="mx_DecryptionFailureBar_end_button" | ||||||||||
kind="primary_outline" | ||||||||||
onClick={onDeviceListClick} | ||||||||||
kind="primary" | ||||||||||
onClick={onVerifyClick} | ||||||||||
data-testid="decryption-failure-bar-button" | ||||||||||
> | ||||||||||
{_t("View your device list")} | ||||||||||
{_t("Verify")} | ||||||||||
</AccessibleButton> | ||||||||||
); | ||||||||||
} else { | ||||||||||
className = "mx_DecryptionFailureBar"; | ||||||||||
// In developerMode, we want to be able to resend manually key requests | ||||||||||
} else if (developerMode && !needsVerification && hasOtherVerifiedDevices && anyUnrequestedSessions) { | ||||||||||
Comment on lines
+174
to
+175
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment should really be inside the relevant
Suggested change
|
||||||||||
className = "mx_DecryptionFailureBar mx_DecryptionFailureBar--withEnd"; | ||||||||||
headline = <React.Fragment>{_t("Some messages could not be decrypted")}</React.Fragment>; | ||||||||||
message = ( | ||||||||||
<React.Fragment> | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. per our DM: this message is incorrect now |
||||||||||
|
@@ -235,11 +183,6 @@ export const DecryptionFailureBar: React.FC<IProps> = ({ failures }) => { | |||||||||
)} | ||||||||||
</React.Fragment> | ||||||||||
); | ||||||||||
} | ||||||||||
|
||||||||||
let keyRequestButton = <React.Fragment />; | ||||||||||
if (!needsVerification && hasOtherVerifiedDevices && anyUnrequestedSessions) { | ||||||||||
className = "mx_DecryptionFailureBar mx_DecryptionFailureBar--withEnd"; | ||||||||||
keyRequestButton = ( | ||||||||||
<AccessibleButton | ||||||||||
className="mx_DecryptionFailureBar_end_button" | ||||||||||
|
@@ -250,6 +193,9 @@ export const DecryptionFailureBar: React.FC<IProps> = ({ failures }) => { | |||||||||
{_t("Resend key requests")} | ||||||||||
</AccessibleButton> | ||||||||||
); | ||||||||||
} else { | ||||||||||
// When we are unable to decrypt the message (no other verified devices), we hide the banner | ||||||||||
return null; | ||||||||||
} | ||||||||||
|
||||||||||
return ( | ||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we only need one of
button
andkeyRequestButton
now