fix forwarding
This commit is contained in:
parent
8270958882
commit
8bf0e9c68d
@ -548,7 +548,9 @@
|
||||
"cchange39": "Cannot send an encrypted message to this user since they do not have their publickey on chain.",
|
||||
"cchange40": "IMAGE (click to view)",
|
||||
"cchange41":"Your Balance Is Under 4.20 QORT",
|
||||
"cchange42":"Out of the need to combat spam, accounts with under 4.20 Qort balance will take a long time to SEND messages in Q-Chat. If you wish to immediately increase the send speed for Q-Chat messages, obtain over 4.20 QORT to your address. This can be done with trades in the Trade Portal, or by way of another Qortian giving you the QORT. Once you have over 4.20 QORT in your account, Q-Chat messages will be instant and this dialog will no more show. Thank you for your understanding of this necessary spam prevention method, and we hope you enjoy Qortal!"
|
||||
"cchange42":"Out of the need to combat spam, accounts with under 4.20 Qort balance will take a long time to SEND messages in Q-Chat. If you wish to immediately increase the send speed for Q-Chat messages, obtain over 4.20 QORT to your address. This can be done with trades in the Trade Portal, or by way of another Qortian giving you the QORT. Once you have over 4.20 QORT in your account, Q-Chat messages will be instant and this dialog will no more show. Thank you for your understanding of this necessary spam prevention method, and we hope you enjoy Qortal!",
|
||||
"cchange62": "Wrong Username and Address Inputted! Please try again!",
|
||||
"cchange63": "Please enter a recipient"
|
||||
|
||||
},
|
||||
"welcomepage": {
|
||||
|
@ -159,7 +159,7 @@ const ADDRESS_VERSION = 58
|
||||
const PROXY_URL = "/proxy/"
|
||||
|
||||
// Chat reference timestamp
|
||||
const CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP = 1674316800000
|
||||
const CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP = 0
|
||||
|
||||
// Used as a salt for all qora addresses. Salts used for storing your private keys in local storage will be randomly generated
|
||||
const STATIC_SALT = new Uint8Array([54, 190, 201, 206, 65, 29, 123, 129, 147, 231, 180, 166, 171, 45, 95, 165, 78, 200, 208, 194, 44, 207, 221, 146, 45, 238, 68, 68, 69, 102, 62, 6])
|
||||
|
@ -900,8 +900,10 @@ class ChatPage extends LitElement {
|
||||
id="sendTo"
|
||||
placeholder="${translate("chatpage.cchange7")}"
|
||||
@keydown=${() => {
|
||||
this.forwardActiveChatHeadUrl = {};
|
||||
this.requestUpdate();
|
||||
if (this.forwardActiveChatHeadUrl.selected) {
|
||||
this.forwardActiveChatHeadUrl = {};
|
||||
this.requestUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
/>
|
||||
@ -977,7 +979,6 @@ class ChatPage extends LitElement {
|
||||
${translate("chatpage.cchange33")}
|
||||
</button>
|
||||
<button
|
||||
?disabled=${!this.forwardActiveChatHeadUrl}
|
||||
class="modal-button"
|
||||
@click=${()=> {
|
||||
this.sendForwardMessage()
|
||||
@ -1030,7 +1031,8 @@ class ChatPage extends LitElement {
|
||||
const nameValue = this.shadowRoot.getElementById('sendTo').value;
|
||||
if (!nameValue) {
|
||||
this.userFound = [];
|
||||
this.userFoundModalOpen = true;
|
||||
this.userFoundModalOpen = false;
|
||||
this.loading = false;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@ -1039,6 +1041,7 @@ class ChatPage extends LitElement {
|
||||
url: `/names/${nameValue}`
|
||||
})
|
||||
if (result.error === 401) {
|
||||
this.loading = false;
|
||||
this.userFound = [];
|
||||
} else {
|
||||
this.userFound = [
|
||||
@ -1048,6 +1051,7 @@ class ChatPage extends LitElement {
|
||||
}
|
||||
this.userFoundModalOpen = true;
|
||||
} catch (error) {
|
||||
this.loading = false;
|
||||
console.error(error);
|
||||
let err4string = get("chatpage.cchange35");
|
||||
parentEpml.request('showSnackBar', `${err4string}`)
|
||||
@ -2118,15 +2122,22 @@ class ChatPage extends LitElement {
|
||||
};
|
||||
|
||||
const sendForwardRequest = async () => {
|
||||
|
||||
const userInput = this.shadowRoot.getElementById("sendTo").value.trim();
|
||||
if(!userInput && !this.forwardActiveChatHeadUrl.url) {
|
||||
let err4string = get("chatpage.cchange63");
|
||||
getSendChatResponse(false, true, err4string );
|
||||
return
|
||||
}
|
||||
let publicKey = {
|
||||
hasPubKey: false,
|
||||
key: ''
|
||||
};
|
||||
|
||||
if (this.forwardActiveChatHeadUrl.url) {
|
||||
const activeChatHeadAddress = this.forwardActiveChatHeadUrl.url.split('/')[1]
|
||||
const activeChatHeadAddress = this.forwardActiveChatHeadUrl.url.split('/')[1];
|
||||
try {
|
||||
const res = await parentEpml.request('apiCall', {
|
||||
const res = await parentEpml.request('apiCall', {
|
||||
type: 'api',
|
||||
url: `/addresses/publickey/${activeChatHeadAddress}`
|
||||
})
|
||||
@ -2146,21 +2157,71 @@ class ChatPage extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.forwardActiveChatHeadUrl && this.shadowRoot.getElementById("sendTo").value !== "") {
|
||||
if (!this.forwardActiveChatHeadUrl.selected && this.shadowRoot.getElementById("sendTo").value !== "") {
|
||||
|
||||
try {
|
||||
const res = await parentEpml.request('apiCall', {
|
||||
let userPubkey = "";
|
||||
const validatedAddress = await parentEpml.request('apiCall', {
|
||||
type: 'api',
|
||||
url: `/addresses/publickey/${this.shadowRoot.getElementById("sendTo").value}`
|
||||
})
|
||||
if (res.error === 102) {
|
||||
publicKey.key = ''
|
||||
publicKey.hasPubKey = false
|
||||
} else if (res !== false) {
|
||||
publicKey.key = res
|
||||
publicKey.hasPubKey = true
|
||||
url: `/addresses/validate/${userInput}`
|
||||
});
|
||||
|
||||
const validatedUsername = await parentEpml.request('apiCall', {
|
||||
type: 'api',
|
||||
url: `/names/${userInput}`
|
||||
});
|
||||
console.log({validatedAddress, validatedUsername })
|
||||
|
||||
if (validatedAddress && validatedUsername.name) {
|
||||
userPubkey = await parentEpml.request('apiCall', {
|
||||
type: 'api',
|
||||
url: `/addresses/publickey/${validatedUsername.owner}`
|
||||
});
|
||||
this.forwardActiveChatHeadUrl = {
|
||||
...this.forwardActiveChatHeadUrl,
|
||||
url: `direct/${validatedUsername.owner}`,
|
||||
name: validatedUsername.name,
|
||||
selected: true
|
||||
};
|
||||
} else
|
||||
if (!validatedAddress && (validatedUsername && !validatedUsername.error)) {
|
||||
userPubkey = await parentEpml.request('apiCall', {
|
||||
type: 'api',
|
||||
url: `/addresses/publickey/${validatedUsername.owner}`
|
||||
});
|
||||
this.forwardActiveChatHeadUrl = {
|
||||
...this.forwardActiveChatHeadUrl,
|
||||
url: `direct/${validatedUsername.owner}`,
|
||||
name: validatedUsername.name,
|
||||
selected: true
|
||||
};
|
||||
} else if (validatedAddress && !validatedUsername.name) {
|
||||
userPubkey = await parentEpml.request('apiCall', {
|
||||
type: 'api',
|
||||
url: `/addresses/publickey/${userInput}`
|
||||
});
|
||||
this.forwardActiveChatHeadUrl = {
|
||||
...this.forwardActiveChatHeadUrl,
|
||||
url: `direct/${userInput}`,
|
||||
name: "",
|
||||
selected: true
|
||||
};
|
||||
} else if (!validatedAddress && !validatedUsername.name) {
|
||||
let err4string = get("chatpage.cchange62");
|
||||
// parentEpml.request('showSnackBar', `${err4string}`);
|
||||
getSendChatResponse(false, true, err4string);
|
||||
return;
|
||||
}
|
||||
|
||||
if (userPubkey.error === 102) {
|
||||
publicKey.key = '';
|
||||
publicKey.hasPubKey = false;
|
||||
} else if (userPubkey !== false) {
|
||||
publicKey.key = userPubkey;
|
||||
publicKey.hasPubKey = true;
|
||||
} else {
|
||||
publicKey.key = ''
|
||||
publicKey.hasPubKey = false
|
||||
publicKey.key = '';
|
||||
publicKey.hasPubKey = false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@ -2175,9 +2236,9 @@ class ChatPage extends LitElement {
|
||||
if (isRecipient === true) {
|
||||
if(!publicKey.hasPubKey){
|
||||
let err4string = get("chatpage.cchange39");
|
||||
parentEpml.request('showSnackBar', `${err4string}`)
|
||||
getSendChatResponse(false)
|
||||
return
|
||||
parentEpml.request('showSnackBar', `${err4string}`);
|
||||
getSendChatResponse(false);
|
||||
return;
|
||||
}
|
||||
let chatResponse = await parentEpml.request('chat', {
|
||||
type: 18,
|
||||
@ -2253,7 +2314,7 @@ class ChatPage extends LitElement {
|
||||
getSendChatResponse(_response, isForward);
|
||||
};
|
||||
|
||||
const getSendChatResponse = (response, isForward) => {
|
||||
const getSendChatResponse = (response, isForward, customErrorMessage) => {
|
||||
if (response === true) {
|
||||
this.chatEditor.resetValue();
|
||||
this.chatEditorNewChat.resetValue()
|
||||
@ -2265,16 +2326,23 @@ class ChatPage extends LitElement {
|
||||
parentEpml.request('showSnackBar', response.message);
|
||||
} else {
|
||||
let err2string = get("chatpage.cchange21");
|
||||
parentEpml.request('showSnackBar', `${err2string}`);
|
||||
parentEpml.request('showSnackBar', `${customErrorMessage || err2string}`);
|
||||
}
|
||||
if(isForward && response !== true){
|
||||
this.isLoading = false;
|
||||
return
|
||||
}
|
||||
|
||||
this.isLoading = false;
|
||||
this.chatEditor.enable();
|
||||
this.chatEditorNewChat.enable()
|
||||
this.closeEditMessageContainer()
|
||||
this.closeRepliedToContainer()
|
||||
this.openForwardOpen = false
|
||||
this.forwardActiveChatHeadUrl = ""
|
||||
this.forwardActiveChatHeadUrl = {
|
||||
url: "",
|
||||
name: "",
|
||||
selected: false
|
||||
}
|
||||
};
|
||||
|
||||
if (isForward) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user