A setting should be added to allow users to hide messages from addresses not in their contacts list behind a 'show message' button. Related to T2418.
Details
- Reviewers
bytesofman - Group Reviewers
Restricted Project - Commits
- rABC771befc108a6: [Cashtab] Hide msgs from unknown senders option
cd web/cashtab && npm start
in the browser:
observe that all messages are visible by default
navigate to settings tab and toggle 'show messages' off
receive a cashtab message from an address not in contact list
receive an encrypted message from an address not in contact list
receive a message from an address that IS in contact list
receive an encrypted message from an address that IS in the contact list
from the home tab:
observe that mesages from contacts are displayed
observe that the 'show message' button is displaying for messages that aren't from contacts
click the 'show message' button on both the encrypted and unencrypted message
observe that the messages are displayed, along with a warning that the sender is not a contact
Diff Detail
- Repository
- rABC Bitcoin ABC
- Branch
- hide-unknown-sender-option
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 19754 Build 39227: Build Diff cashtab-tests Build 39226: arc lint + arc unit
Event Timeline
This has the same issue as D11602. Need to get a function to handle partially valid cashtab settings.
Rebased to master, updated validation test for parseInvalidSettingsForMigration function to include new default setting and added logic to hide the 'Hide' button on outgoing messages.
Get in the habit of keeping the dev console open during testing so you can catch these React errors.
web/cashtab/src/components/Home/Tx.js | ||
---|---|---|
766 ↗ | (On Diff #34547) | See other comment |
786 ↗ | (On Diff #34547) | See other comment |
812 ↗ | (On Diff #34547) | See other comment |
831 ↗ | (On Diff #34547) | See other comment |
857 ↗ | (On Diff #34547) | The <Link> component needs a to prop, and should not be used for cases like this where you are triggering some sort of functionality rather than navigating somewhere. Replace with a <button>, or ideally a custom styled component button. |
Replaced Links with custom styled button component. Small styling changes have been made to accommodate the new button component. Updated snapshots.
web/cashtab/src/components/Configure/Configure.js | ||
---|---|---|
1882 | Not sure why the removal of <SettingsLinkCtn> is part of this diff...is this not solved by a rebase? Was this container removed as part of this diff? I am seeing it in the latest master. Why was this removed? | |
web/cashtab/src/components/Home/Tx.js | ||
698 | Why null and not false? | |
769 | Above, you have the app displaying something {!cashtabSettings.showMessages && Here, you have the app displaying something {cashtabSettings.showMessages && ( It will always be one or the other. So, it is better practice to use conditional rendering like `{cashtabSettings.showMessages ? <>the thing to show if it's true<> : <>the thing to show if it's false<>} |
web/cashtab/src/components/Home/Tx.js | ||
---|---|---|
384 ↗ | (On Diff #34594) | This should be passed into the Tx component as a prop, because it does not differ for each tx.
|
web/cashtab/src/components/Home/Tx.js | ||
---|---|---|
729 ↗ | (On Diff #34646) | Seems like a confusing boolean. The boolean showMessages, if true, creates a condition where messages are hidden by default? Am I reading this right? |
773 ↗ | (On Diff #34646) | If you are saying "if this, display a bunch of components, otherwise display an empty string" needs to be a good reason to just display the empty string. Otherwise, use {data.opReturnMessage && !data.isEncryptedMessage && ( Maybe I misinterpreted the code when I earlier asked to use the ? : conditional style. It should always be used if there are 2 cases and you are displaying one thing or the other. If you are displaying something or nothing, use && |
816 ↗ | (On Diff #34646) | see above |
838 ↗ | (On Diff #34646) | The presence or absence of this <UnauthorizedDecryptionMessage> component seems to be the only difference in code between {/*encrypted and wallet is authorized to view OP_RETURN Message*/} and {/*encrypted but wallet is not authorized to view OP_RETURN Message*/} Yet all of this other surrounding stuff is duplicated. Conditional rendering should be limited only to what is necessary. This also makes the code easier to read -- it's quite difficult to review this code and find out exactly what is changing depending on the conditions. In this case, you can have conditional rendering inside this component, either showing <p> {data.opReturnMessage} </p> or <UnauthorizedDecryptionMessage> {data.opReturnMessage} </UnauthorizedDecryptionMessage> depending on data.decryptionSuccess Another, probably better approach would be to have a styled component <DecryptedMsg> that accepts authorized={data.decryptionSuccess} as a boolean prop. Then add a styled component rule to change the styling...conventional <p> if authorized={true} and <UnauthorizedDecryptionMessage> otherwise. There are some other styled components in Cashtab that use this type of logic. You should always be looking to write the absolute minimum code required to implement a change. |
Per review feedback:
Changed showMessage setting to hideMessagesFromUnknownSenders - I believe this orignally was a result of the toggle reading "Show Messages From Unknown Senders," until it was decided to turn the option off by default.
Removed unnecessary conditional rendering at ln 773 & 816.
Created styled component DecryptedMessage which accepts authorized={data.decryptionSuccess} as a boolean prop. If the msg cannot be decrypted, styling for UnauthorizedDecryptionMessage is used, otherwise, the regular <p> styling is used.
Unrelated to feedback:
Hide button no longer appears for encrypted messages as there is nothing to hide.
web/cashtab/src/components/Home/Tx.js | ||
---|---|---|
1007 ↗ | (On Diff #34710) | note that cashtabSettings is a boolean (false) when the app first loads, as loading them from localstorage is async. Proptypes should reflect this Again, need to always run with the dev console open and check for these types of msgs: |
web/cashtab/src/components/Home/TxHistory.js | ||
42 ↗ | (On Diff #34710) | same as above |