diff --git a/qortal-ui-plugins/plugins/core/components/ChatModals.js b/qortal-ui-plugins/plugins/core/components/ChatModals.js index b7370ef3..c9daf3b4 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatModals.js +++ b/qortal-ui-plugins/plugins/core/components/ChatModals.js @@ -92,11 +92,11 @@ class ChatModals extends LitElement { // Send Private Message _sendMessage() { - this.isLoading = true + this.isLoading = true; - const recipient = this.shadowRoot.getElementById('sendTo').value - const messageBox = this.shadowRoot.getElementById('messageBox') - const messageText = messageBox.value + const recipient = this.shadowRoot.getElementById('sendTo').value; + const messageBox = this.shadowRoot.getElementById('messageBox'); + const messageText = messageBox.value; if (recipient.length === 0) { this.isLoading = false @@ -105,22 +105,21 @@ class ChatModals extends LitElement { } else { this.sendMessage() } - } + }; async sendMessage() { - this.isLoading = true - - const _recipient = this.shadowRoot.getElementById('sendTo').value - const messageBox = this.shadowRoot.getElementById('messageBox') - const messageText = messageBox.value - let recipient + this.isLoading = true; + const _recipient = this.shadowRoot.getElementById('sendTo').value; + const messageBox = this.shadowRoot.getElementById('messageBox'); + const messageText = messageBox.value; + let recipient; const validateName = async (receiverName) => { - let myRes + let myRes; let myNameRes = await parentEpml.request('apiCall', { type: 'api', url: `/names/${receiverName}` - }) + }); if (myNameRes.error === 401) { myRes = false @@ -128,7 +127,7 @@ class ChatModals extends LitElement { myRes = myNameRes } - return myRes + return myRes; } const myNameRes = await validateName(_recipient) @@ -139,7 +138,6 @@ class ChatModals extends LitElement { recipient = myNameRes.owner } - let _reference = new Uint8Array(64); window.crypto.getRandomValues(_reference); @@ -367,7 +365,11 @@ class ChatModals extends LitElement {

- ${translate('welcomepage.wcchange6')} + { + console.log("here500"); + this._sendMessage(); + } + }>${translate('welcomepage.wcchange6')} ${translate("chatpage.cchange22")}` : this.renderChatScroller(this._initialMessages)} -
-
- ${this.repliedToMessageObj && html` -
-
- -
-

${this.repliedToMessageObj.senderName ? this.repliedToMessageObj.senderName : this.repliedToMessageObj.sender}

-

${this.repliedToMessageObj.message}

+
+
+ ${this.isLoadingMessages ? html`

${translate("chatpage.cchange22")}

` : this.renderChatScroller(this._initialMessages)} +
+
+
+ ${this.repliedToMessageObj && html` +
+
+ +
+

${this.repliedToMessageObj.senderName ? this.repliedToMessageObj.senderName : this.repliedToMessageObj.sender}

+

${this.repliedToMessageObj.message}

+
+ this.closeRepliedToContainer()} + >
- this.closeRepliedToContainer()} - > -
- `} - ${this.editedMessageObj && html` -
-
- -
-

${translate("chatpage.cchange25")}

-

${this.editedMessageObj.message}

+ `} + ${this.editedMessageObj && html` +
+
+ +
+

${translate("chatpage.cchange25")}

+

${this.editedMessageObj.message}

+
+ this.closeEditMessageContainer()} + >
- this.closeEditMessageContainer()} - > -
- `} -
- - - - ${this.editedMessageObj ? ( - html` - this._sendMessage()} - > - ` - ) : html`
` - } + `} +
+ + + + ${this.editedMessageObj ? ( + html` + this._sendMessage()} + > + ` + ) : html`
` + } +
@@ -274,7 +278,6 @@ class ChatPage extends LitElement { } async firstUpdated() { - // TODO: Load and fetch messages from localstorage (maybe save messages to localstorage...) @@ -385,6 +388,7 @@ class ChatPage extends LitElement { parentEpml.imReady(); } + async updated(changedProperties) { if (changedProperties.has('messagesRendered')) { const chatReference1 = this.isReceipient ? 'direct' : 'group'; diff --git a/qortal-ui-plugins/plugins/core/components/ChatWelcomePage.js b/qortal-ui-plugins/plugins/core/components/ChatWelcomePage.js index 14735c00..3d99c340 100644 --- a/qortal-ui-plugins/plugins/core/components/ChatWelcomePage.js +++ b/qortal-ui-plugins/plugins/core/components/ChatWelcomePage.js @@ -230,7 +230,11 @@ class ChatWelcomePage extends LitElement {

- ${translate("welcomepage.wcchange6")} + { + this._sendMessage(); + } + }> + ${translate("welcomepage.wcchange6")} { - let myRes + let myRes; let myNameRes = await parentEpml.request('apiCall', { type: 'api', url: `/names/${receiverName}` - }) - + }); if (myNameRes.error === 401) { - myRes = false + myRes = false; } else { - myRes = myNameRes - } + myRes = myNameRes; + }; + return myRes; + }; - return myRes - } + const myNameRes = await validateName(_recipient); - const myNameRes = await validateName(_recipient) if (!myNameRes) { - - recipient = _recipient + recipient = _recipient; } else { - - recipient = myNameRes.owner - } + recipient = myNameRes.owner; + }; let _reference = new Uint8Array(64); window.crypto.getRandomValues(_reference); - let sendTimestamp = Date.now() + let sendTimestamp = Date.now(); - let reference = window.parent.Base58.encode(_reference) + let reference = window.parent.Base58.encode(_reference); const getAddressPublicKey = async () => { - let isEncrypted - let _publicKey + let isEncrypted; + let _publicKey; let addressPublicKey = await parentEpml.request('apiCall', { type: 'api', url: `/addresses/publickey/${recipient}` }) - if (addressPublicKey.error === 102) { - _publicKey = false + _publicKey = false; // Do something here... - let err1string = get("welcomepage.wcchange7") - parentEpml.request('showSnackBar', `${err1string}`) - this.isLoading = false + let err1string = get("welcomepage.wcchange7"); + parentEpml.request('showSnackBar', `${err1string}`); + this.isLoading = false; } else if (addressPublicKey !== false) { - isEncrypted = 1 - _publicKey = addressPublicKey - sendMessageRequest(isEncrypted, _publicKey) + isEncrypted = 1; + _publicKey = addressPublicKey; + sendMessageRequest(isEncrypted, _publicKey); } else { - isEncrypted = 0 - _publicKey = this.selectedAddress.address - sendMessageRequest(isEncrypted, _publicKey) - } + isEncrypted = 0; + _publicKey = this.selectedAddress.address; + sendMessageRequest(isEncrypted, _publicKey); + }; }; const sendMessageRequest = async (isEncrypted, _publicKey) => { @@ -407,8 +405,8 @@ class ChatWelcomePage extends LitElement { images: [''], repliedTo: '', version: 1 - } - const stringifyMessageObject = JSON.stringify(messageObject) + }; + const stringifyMessageObject = JSON.stringify(messageObject); let chatResponse = await parentEpml.request('chat', { type: 18, nonce: this.selectedAddress.nonce, @@ -424,7 +422,6 @@ class ChatWelcomePage extends LitElement { isText: 1 } }) - _computePow(chatResponse) } diff --git a/qortal-ui-plugins/plugins/core/components/NameMenu.js b/qortal-ui-plugins/plugins/core/components/NameMenu.js index 9b1a9635..8e1363c6 100644 --- a/qortal-ui-plugins/plugins/core/components/NameMenu.js +++ b/qortal-ui-plugins/plugins/core/components/NameMenu.js @@ -232,7 +232,11 @@ class NameMenu extends LitElement {

- ${translate("welcomepage.wcchange6")} + { + this._sendMessage(); + } + }> + ${translate("welcomepage.wcchange6")}