diff --git a/web/cashtab/src/components/Common/Ticker.js b/web/cashtab/src/components/Common/Ticker.js --- a/web/cashtab/src/components/Common/Ticker.js +++ b/web/cashtab/src/components/Common/Ticker.js @@ -25,7 +25,11 @@ tokenDbUrl: 'https://tokendb.kingbch.com', txHistoryCount: 10, xecApiBatchSize: 20, - defaultSettings: { fiatCurrency: 'usd', sendModal: false }, + defaultSettings: { + fiatCurrency: 'usd', + sendModal: false, + showMessages: true, + }, notificationDurationShort: 3, notificationDurationLong: 5, localStorageMaxCharacters: 24, @@ -72,6 +76,7 @@ 'chf', ], sendModal: [true, false], + showMessages: [true, false], }, fiatCurrencies: { usd: { name: 'US Dollar', symbol: '$', slug: 'usd' }, diff --git a/web/cashtab/src/components/Configure/Configure.js b/web/cashtab/src/components/Configure/Configure.js --- a/web/cashtab/src/components/Configure/Configure.js +++ b/web/cashtab/src/components/Configure/Configure.js @@ -431,6 +431,9 @@ .SendConfirm { color: ${props => props.theme.lightWhite}; } + .ShowMessages { + color: ${props => props.theme.lightWhite}; + } `; const Configure = () => { @@ -909,6 +912,9 @@ changeCashtabSettings('sendModal', checkedState); }; + const handleUnknownSenderMsg = checkedState => { + changeCashtabSettings('showMessages', checkedState); + }; const getContactNameByAddress = contactAddress => { if (!contactAddress) { return; @@ -1797,6 +1803,22 @@ onChange={handleSendModalToggle} /> + +
+ Show Msgs From Unknown Sender +
+ } + unCheckedChildren={} + checked={ + cashtabSettings + ? cashtabSettings.showMessages + : true + } + onChange={handleUnknownSenderMsg} + /> +
[
+
+
+ + + + Show Msgs From Unkown Sender +
+ +
@@ -835,7 +898,7 @@ General Settings
+
+
+ + + + Show Msgs From Unkown Sender +
+ +
diff --git a/web/cashtab/src/components/Home/Tx.js b/web/cashtab/src/components/Home/Tx.js --- a/web/cashtab/src/components/Home/Tx.js +++ b/web/cashtab/src/components/Home/Tx.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import { Link } from 'react-router-dom'; import PropTypes from 'prop-types'; import styled from 'styled-components'; @@ -10,6 +10,7 @@ ThemedContactsOutlined, } from 'components/Common/CustomIcons'; import { currency } from 'components/Common/Ticker'; +import { WalletContext } from 'utils/context'; import { fromLegacyDecimals } from 'utils/cashMethods'; import { formatBalance, formatDate } from 'utils/formatting'; import TokenIcon from 'components/Tokens/TokenIcon'; @@ -329,6 +330,14 @@ `; const Tx = ({ data, fiatPrice, fiatCurrency, addressesInContactList }) => { + const ContextValue = React.useContext(WalletContext); + const { cashtabSettings } = ContextValue; + const [displayedMessage, setDisplayedMessage] = useState(false); + + const handleShowMessage = () => { + setDisplayedMessage(!displayedMessage); + }; + const txDate = typeof data.blocktime === 'undefined' ? formatDate() @@ -598,7 +607,8 @@ {!data.outgoingTx && !addressesInContactList.includes( data.replyAddress, - ) && ( + ) && + displayedMessage && ( Warning: This sender is not in @@ -624,40 +634,189 @@ '' )}
- {/*unencrypted OP_RETURN Message*/} - {data.opReturnMessage && - !data.isEncryptedMessage ? ( -

- { - data.opReturnMessage - } -

- ) : ( - '' - )} - {/*encrypted and wallet is authorized to view OP_RETURN Message*/} - {data.opReturnMessage && - data.isEncryptedMessage && - data.decryptionSuccess ? ( -

- { - data.opReturnMessage - } -

- ) : ( - '' + {cashtabSettings.showMessages && ( + <> + {/*unencrypted OP_RETURN Message*/} + {data.opReturnMessage && + !data.isEncryptedMessage ? ( +

+ { + data.opReturnMessage + } +

+ ) : ( + '' + )} + {/*encrypted and wallet is authorized to view OP_RETURN Message*/} + {data.opReturnMessage && + data.isEncryptedMessage && + data.decryptionSuccess ? ( +

+ { + data.opReturnMessage + } +

+ ) : ( + '' + )} + {/*encrypted but wallet is not authorized to view OP_RETURN Message*/} + {data.opReturnMessage && + data.isEncryptedMessage && + !data.decryptionSuccess ? ( + + { + data.opReturnMessage + } + + ) : ( + '' + )} + )} - {/*encrypted but wallet is not authorized to view OP_RETURN Message*/} - {data.opReturnMessage && - data.isEncryptedMessage && - !data.decryptionSuccess ? ( - - { - data.opReturnMessage - } - - ) : ( - '' + {!cashtabSettings.showMessages && ( + <> + {/*unencrypted OP_RETURN Message*/} + {data.opReturnMessage && + !data.isEncryptedMessage ? ( + <> + {!displayedMessage && + !data.outgoingTx && + !addressesInContactList.includes( + data.replyAddress, + ) ? ( + { + e.stopPropagation(); + handleShowMessage(); + }} + href="#" + > + Show + Message + + ) : ( + <> +

+ { + data.opReturnMessage + } +

+ {!addressesInContactList.includes( + data.replyAddress, + ) && ( + { + e.stopPropagation(); + handleShowMessage(); + }} + href="#" + > + Hide + Message + + )} + + )} + + ) : ( + '' + )} + {/*encrypted and wallet is authorized to view OP_RETURN Message*/} + {data.opReturnMessage && + data.isEncryptedMessage && + data.decryptionSuccess ? ( + <> + {!displayedMessage && + !data.outgoingTx && + !addressesInContactList.includes( + data.replyAddress, + ) ? ( + { + e.stopPropagation(); + handleShowMessage(); + }} + href="#" + > + Show + Message + + ) : ( + <> +

+ { + data.opReturnMessage + } +

+ {!addressesInContactList.includes( + data.replyAddress, + ) && ( + { + e.stopPropagation(); + handleShowMessage(); + }} + href="#" + > + Hide + Message + + )} + + )} + + ) : ( + '' + )} + {/*encrypted but wallet is not authorized to view OP_RETURN Message*/} + {data.opReturnMessage && + data.isEncryptedMessage && + !data.decryptionSuccess ? ( + <> + {!displayedMessage && + !data.outgoingTx && + !addressesInContactList.includes( + data.replyAddress, + ) ? ( + { + e.stopPropagation(); + handleShowMessage(); + }} + href="#" + > + Show + Message + + ) : ( + <> + + { + data.opReturnMessage + } + + {!addressesInContactList.includes( + data.replyAddress, + ) && + !data.outgoingTx && ( + { + e.stopPropagation(); + handleShowMessage(); + }} + href="#" + > + Hide + Message + + )} + + )} + + ) : ( + '' + )} + )} {!data.outgoingTx && data.replyAddress ? (