mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-14 11:15:50 +00:00
no publickey condition
This commit is contained in:
parent
664e8d4f8c
commit
0d1646b2b5
@ -1673,6 +1673,39 @@ class ChatPage extends LitElement {
|
||||
}
|
||||
|
||||
async _sendMessage(outSideMsg) {
|
||||
|
||||
if(this.isReceipient){
|
||||
let hasPublicKey = true
|
||||
if(!this._publicKey.hasPubKey){
|
||||
hasPublicKey = false
|
||||
try {
|
||||
const res = await parentEpml.request('apiCall', {
|
||||
type: 'api',
|
||||
url: `/addresses/publickey/${this.selectedAddress.address}`
|
||||
})
|
||||
if (res.error === 102) {
|
||||
this._publicKey.key = ''
|
||||
this._publicKey.hasPubKey = false
|
||||
} else if (res !== false) {
|
||||
this._publicKey.key = res
|
||||
this._publicKey.hasPubKey = true
|
||||
hasPublicKey = true
|
||||
} else {
|
||||
this._publicKey.key = ''
|
||||
this._publicKey.hasPubKey = false
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
if(!hasPublicKey || !this._publicKey.hasPubKey){
|
||||
let err4string = get("chatpage.cchange39");
|
||||
parentEpml.request('showSnackBar', `${err4string}`)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
console.log(outSideMsg);
|
||||
// have params to determine if it's a reply or not
|
||||
// have variable to determine if it's a response, holds signature in constructor
|
||||
@ -1997,7 +2030,7 @@ class ChatPage extends LitElement {
|
||||
message: messageText,
|
||||
lastReference: reference,
|
||||
proofOfWorkNonce: 0,
|
||||
isEncrypted: this._publicKey.hasPubKey === false ? 0 : 1,
|
||||
isEncrypted: 1,
|
||||
isText: 1
|
||||
}
|
||||
});
|
||||
@ -2081,6 +2114,12 @@ class ChatPage extends LitElement {
|
||||
this.openForwardOpen = false;
|
||||
this.chatEditor.enable();
|
||||
if (isRecipient === true) {
|
||||
if(!publicKey.hasPubKey){
|
||||
let err4string = get("chatpage.cchange39");
|
||||
parentEpml.request('showSnackBar', `${err4string}`)
|
||||
getSendChatResponse(false)
|
||||
return
|
||||
}
|
||||
let chatResponse = await parentEpml.request('chat', {
|
||||
type: 18,
|
||||
nonce: this.selectedAddress.nonce,
|
||||
@ -2093,7 +2132,7 @@ class ChatPage extends LitElement {
|
||||
message: messageText,
|
||||
lastReference: reference,
|
||||
proofOfWorkNonce: 0,
|
||||
isEncrypted: publicKey.hasPubKey === false ? 0 : 1,
|
||||
isEncrypted: 1,
|
||||
isText: 1
|
||||
}
|
||||
});
|
||||
|
@ -199,7 +199,11 @@ class Chat extends LitElement {
|
||||
</button>
|
||||
<button
|
||||
class="modal-button"
|
||||
@click=${this._sendMessage}
|
||||
@click=${()=> {
|
||||
this.chatEditor.updateMirror()
|
||||
this._sendMessage()
|
||||
|
||||
}}
|
||||
?disabled="${this.isLoading}">
|
||||
${this.isLoading === false
|
||||
? this.renderSendText()
|
||||
@ -501,9 +505,10 @@ class Chat extends LitElement {
|
||||
_publicKey = addressPublicKey;
|
||||
sendMessageRequest(isEncrypted, _publicKey);
|
||||
} else {
|
||||
isEncrypted = 0;
|
||||
_publicKey = this.selectedAddress.address;
|
||||
sendMessageRequest(isEncrypted, _publicKey);
|
||||
let err4string = get("chatpage.cchange39");
|
||||
parentEpml.request('showSnackBar', `${err4string}`);
|
||||
this.chatEditor.enable();
|
||||
this.isLoading = false;
|
||||
}
|
||||
};
|
||||
let _reference = new Uint8Array(64);
|
||||
@ -521,7 +526,7 @@ class Chat extends LitElement {
|
||||
message: messageText,
|
||||
lastReference: reference,
|
||||
proofOfWorkNonce: 0,
|
||||
isEncrypted: isEncrypted,
|
||||
isEncrypted: 1,
|
||||
isText: 1
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user