Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Commit

Permalink
Merge branch 'qa-testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
jk authored and jk committed Jul 30, 2020
2 parents 09ca255 + 6fa2986 commit c34ed38
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 22 deletions.
11 changes: 10 additions & 1 deletion src/renderer/components/ui/SentFundsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export const SentFundsModal = ({
timeTransaction.slice(pos + 1) +
' ' +
DateTime.local().offsetNameShort

return (
<Modal open={open} handleClose={handleClose}>
<AutoSizer>
Expand Down Expand Up @@ -195,6 +194,16 @@ export const SentFundsModal = ({
)}
</Grid>
</Grid>
{feeZec > 0 && (
<Grid item container className={classes.field} xs={12}>
<Grid item className={classes.label}>
Network fee
</Grid>
<Grid item className={classes.total} xs>
{(parseFloat(feeZec))} ZEC
</Grid>
</Grid>
)}
<Grid item container className={classes.field} xs={12}>
<Grid item className={classes.label}>
Total
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/ui/SentFundsModal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('SentFundsModal', () => {
handleClose={() => {}}
amountUsd={12}
feeUsd={0}
feeZec={0}
feeZec={0.1}
memo='random text'
timestamp={DateTime.utc(2017).toSeconds()}
valueWhenSent={100}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ export const ChannelInput = ({
inputRef.current.el.current.focus()
setFocused(true)
}
const scrollToBottom = () => {
const scroll = document.getElementById('messages-scroll').parentElement
scroll.scrollTop = scroll.scrollHeight
}
React.useEffect(() => {
inputRef.current.updater.enqueueForceUpdate(inputRef.current)
}, [inputPlaceholder])
Expand Down Expand Up @@ -235,7 +239,10 @@ export const ChannelInput = ({
}
for (const key in splitedMsg) {
const element = splitedMsg[key]
if (element.startsWith('@') && users.find(user => user.nickname === element.substring(1))) {
if (
element.startsWith('@') &&
users.find(user => user.nickname === element.substring(1))
) {
splitedMsg[key] = renderToString(
<span className={classes.highlight}>{element}</span>
)
Expand Down Expand Up @@ -391,6 +398,7 @@ export const ChannelInput = ({
inputState === INPUT_STATE.AVAILABLE &&
e.nativeEvent.keyCode === 13
) {
scrollToBottom()
onKeyPress(e)
} else {
if (e.nativeEvent.keyCode === 13) {
Expand Down Expand Up @@ -441,6 +449,7 @@ export const ChannelInput = ({
<Picker
onEmojiClick={(e, emoji) => {
setHtmlMessage(message + emoji.emoji)
onChange(message + emoji.emoji)
setOpenEmoji(false)
}}
/>
Expand All @@ -461,7 +470,9 @@ export const ChannelInput = ({
{`Your message is over the size limit. `}
<span
onClick={() =>
shell.openExternal('https://www.zbay.app/faq.html#message-size-info')
shell.openExternal(
'https://www.zbay.app/faq.html#message-size-info'
)
}
className={classes.linkBlue}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const ChannelMessages = ({
<List
disablePadding
ref={msgRef}
id='messages-scroll'
className={classes.list}
style={{ marginTop: offset }}
>
Expand Down
11 changes: 6 additions & 5 deletions src/renderer/components/widgets/channels/ItemTransferMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const ItemTransferMessage = ({
rateUsd,
openSentModal,
currentBlock,
isRegisteredUsername
isRegisteredNickname
}) => {
const [actionsOpen, setActionsOpen] = React.useState(false)
const usdAmount = new BigNumber(message.spent)
Expand All @@ -100,18 +100,19 @@ export const ItemTransferMessage = ({
>
<Grid
className={classes.messageInput}
onClick={() =>
onClick={() => {
openSentModal({
fromYou: true,
provideShipping: message.provideShipping,
amountZec: parseFloat(message.spent.toString()),
txid: message.id,
memo: message.message,
recipient: message.receiver.replyTo,
recipient: message.receiver ? message.receiver.replyTo : '',
timestamp: message.createdAt,
blockTime: message.blockTime
})
}
}
item
>
{currentBlock - message.blockTime < 24 ? (
Expand All @@ -125,7 +126,7 @@ export const ItemTransferMessage = ({
<Typography variant='body2' className={classes.data}>
{message.fromYou
? `You sent ${message.offerOwner ||
isRegisteredUsername ? `@${message.receiver.username}` : message.receiver.replyTo} $${usdAmount} (${parseFloat(
isRegisteredNickname ? `@${message.receiver.username}` : message.receiver.replyTo} $${usdAmount} (${parseFloat(
message.spent.toString()
).toFixed(4)} ZEC) ${message.tag ? `for #${message.tag}` : ''}`
: `Received from @${message.sender.username} $${usdAmount} (${
Expand Down Expand Up @@ -155,7 +156,7 @@ ItemTransferMessage.propTypes = {
currentBlock: PropTypes.number.isRequired,
openSentModal: PropTypes.func.isRequired,
message: PropTypes.instanceOf(_DisplayableMessage).isRequired,
isRegisteredUsername: PropTypes.bool
isRegisteredNickname: PropTypes.bool
}

export default R.compose(React.memo, withStyles(styles))(ItemTransferMessage)
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exports[`ChannelMessages renders component 1`] = `
<WithStyles(ForwardRef(List))
className="list-mock"
disablePadding={true}
id="messages-scroll"
style={
Object {
"marginTop": 0,
Expand Down
22 changes: 12 additions & 10 deletions src/renderer/store/handlers/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,18 @@ export const fetchMessages = channel => async (dispatch, getState) => {
newMessages.map(nm =>
displayMessageNotification({ message: nm, channel })
)
}
if (
username &&
(userFilter === notificationFilterType.ALL_MESSAGES ||
userFilter === notificationFilterType.MENTIONS) &&
filterType === notificationFilterType.MENTIONS
) {
newMessages
.filter(msg => containsString(msg.message, `@${username.nickname}`))
.map(nm => displayMessageNotification({ message: nm, channel }))
} else {
if (
username &&
(userFilter === notificationFilterType.MENTIONS ||
userFilter === notificationFilterType.ALL_MESSAGES) &&
(filterType === notificationFilterType.MENTIONS ||
filterType === notificationFilterType.ALL_MESSAGES)
) {
newMessages
.filter(msg => containsString(msg.message, `@${username.nickname}`))
.map(nm => displayMessageNotification({ message: nm, channel }))
}
}
}
return 1
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/store/handlers/rates.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ export const fetchPriceForTime = time => async (dispatch, getState) => {
: prev
})
const txn = transfers.find(txn => txn.txid === closesTransaction)
return parseFloat(Buffer.from(txn.memo, 'hex').toString())
const txnMemo = trimNull(Buffer.from(txn.memo, 'hex').toString())
const price = trimNull(txnMemo.substring(129))
return parseFloat(price)
} catch (err) {
console.warn(err)
}
Expand Down
8 changes: 6 additions & 2 deletions src/renderer/zbay/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,12 @@ export const getPublicKeysFromSignature = message => {
export const createMessage = ({ messageData, privKey }) => {
return signMessage({ messageData, privKey })
}
export const shippingDataToString = values =>
`\n\n Ship to: \n${values.shippingData.firstName} ${values.shippingData.lastName}\n${values.shippingData.country} ${values.shippingData.region} \n ${values.shippingData.city} ${values.shippingData.street} ${values.shippingData.postalCode}`
export const shippingDataToString = values => {
if (!values.shippingData) {
return ''
}
return `\n\n Ship to: \n${values.shippingData.firstName} ${values.shippingData.lastName}\n${values.shippingData.country} ${values.shippingData.region} \n ${values.shippingData.city} ${values.shippingData.street} ${values.shippingData.postalCode}`
}
export const createTransfer = values => {
let memo = values.memo
if (values.shippingInfo) {
Expand Down

0 comments on commit c34ed38

Please sign in to comment.