diff --git a/src/main/websockets/client.js b/src/main/websockets/client.js index cdf510cd7..2fcd286a9 100644 --- a/src/main/websockets/client.js +++ b/src/main/websockets/client.js @@ -29,6 +29,7 @@ export const connect = address => console.log(err) }) socket.on('open', async function (a) { + console.log('opened websocket client connection') const privKey = identity.signerPrivKey const message = messages.createMessage({ messageData: { diff --git a/src/renderer/components/widgets/channels/ChannelMessages.tsx b/src/renderer/components/widgets/channels/ChannelMessages.tsx index 0d8159da0..42df28502 100644 --- a/src/renderer/components/widgets/channels/ChannelMessages.tsx +++ b/src/renderer/components/widgets/channels/ChannelMessages.tsx @@ -179,89 +179,84 @@ export const ChannelMessages: React.FC = ({ ref={scrollbarRef} autoHideTimeout={500} renderView={renderView} - onScrollFrame={onScrollFrame} - > + onScrollFrame={onScrollFrame}> - {isOwner && } - + style={{ marginTop: offset }}> + {isOwner && } + {!isRescanned && !isDM && } {/* {isOffer && !showLoader && ( )} */} {Object.keys(groupedMessages || []).map((key, i) => { - const messagesArray = groupedMessages[key]; - const today = DateTime.utc(); - const groupName = DateTime.fromSeconds(parseInt(key)).toFormat( - "cccc, LLL d" - ); - const displayTitle = DateTime.fromSeconds(parseInt(key)).hasSame( - today, - "day" - ) - ? "Today" - : groupName; + const messagesArray = groupedMessages[key] + const today = DateTime.utc() + const groupName = DateTime.fromSeconds(parseInt(key)).toFormat('cccc, LLL d') + const displayTitle = DateTime.fromSeconds(parseInt(key)).hasSame(today, 'day') + ? 'Today' + : groupName return ( <> - {messagesArray.map((msg) => { - const MessageComponent = typeToMessageComponent[msg.type]; + {messagesArray.map(msg => { + const MessageComponent = typeToMessageComponent[msg.type] if (!msg.type) { if (msg.keys) { return ( { - onLinkedChannel(publicChannels[msg.name]); + onLinkedChannel(publicChannels[msg.name]) }} /> - ); + ) } else { - return ; + return } } - return ( - - ); + return })} - ); + ) })} - { isDM && ( - - - {isConnected ? Connected to @{name} via Tor. Your message will be sent directly, not via Zcash memo. : Disconnected from @{name}. Your message will be sent via Zcash memo.} - + {isDM && name && ( + + + + {isConnected ? ( + + Connected to @{name} via Tor. Your message + will be sent directly, not via Zcash memo. + + ) : ( + + Disconnected from @{name}. Your message + will be sent via Zcash memo. + + )} + + - - ) - } + )} {isNewUser && ( - Welcome to Zbay! To start quickly, Zbay includes username and - channel registration data in the app itself. To verify this - data, which takes ~1 hour but may add some security, + Welcome to Zbay! To start quickly, Zbay includes username and channel registration + data in the app itself. To verify this data, which takes ~1 hour but may add some + security, - {" "} + {' '} restart & re-sync . Otherwise, say hi and introduce yourself! @@ -271,7 +266,7 @@ export const ChannelMessages: React.FC = ({ )} - ); + ) }; const typeToMessageComponent = { diff --git a/src/renderer/store/handlers/messages.ts b/src/renderer/store/handlers/messages.ts index c9a8448cc..e2e67ed0d 100644 --- a/src/renderer/store/handlers/messages.ts +++ b/src/renderer/store/handlers/messages.ts @@ -608,12 +608,23 @@ export const handleWebsocketMessage = data => async (dispatch, getState) => { } publicKey = getPublicKeysFromSignature(message).toString('hex') const contact = contactsSelectors.contact(publicKey)(getState()) - if (type === messageType.CONNECTION_ESTABLISHED) { - if (!contact.connected) { - //dispatch(contactsHandlers.actions.setContactConnected({ connected: true, key: publicKey })) - dispatch(contactsHandlers.epics.connectWsContacts(publicKey)) + if (contact) { + dispatch( + contactsHandlers.actions.setTypingIndicator({ + typingIndicator: !!typeIndicator, + contactAddress: publicKey + }) + ) + console.log('Received connection established message') + if (type === messageType.CONNECTION_ESTABLISHED) { + console.log('Contact exist') + if (!contact.connected) { + console.log('Contact is not connected, initializing connection') + //dispatch(contactsHandlers.actions.setContactConnected({ connected: true, key: publicKey })) + dispatch(contactsHandlers.epics.connectWsContacts(publicKey)) + } + return } - return } if (users !== undefined) { const fromUser = users[publicKey] @@ -631,12 +642,6 @@ export const handleWebsocketMessage = data => async (dispatch, getState) => { isUnregistered = true } } - dispatch( - contactsHandlers.actions.setTypingIndicator({ - typingIndicator: !!typeIndicator, - contactAddress: publicKey - }) - ) } catch (err) { console.warn(err) return null @@ -719,6 +724,7 @@ export const handleWebsocketMessage = data => async (dispatch, getState) => { username: msg.sender.username }) ) + dispatch(contactsHandlers.epics.connectWsContacts(publicKey)) } dispatch( contactsHandlers.actions.addMessage({ diff --git a/src/renderer/store/handlers/users.ts b/src/renderer/store/handlers/users.ts index bc49d8a66..9fd7ee59b 100644 --- a/src/renderer/store/handlers/users.ts +++ b/src/renderer/store/handlers/users.ts @@ -322,7 +322,9 @@ export const registerOnionAddress = torStatus => async (dispatch, getState) => { }) // dispatch(actionCreators.closeModal('accountSettingsModal')()) const txid = await client.sendTransaction(transfer) + console.log('sending transaction with onion address') if (txid.error) { + console.log('error while sending transaction with onion address') throw new Error(txid.error) } dispatch(