mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-04-19 09:35:54 +00:00
fixed a couple bugs
This commit is contained in:
parent
0b613beed6
commit
78942e6bd9
@ -55,10 +55,10 @@ const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
|
|||||||
|
|
||||||
export const queue = new RequestQueue();
|
export const queue = new RequestQueue();
|
||||||
|
|
||||||
export const chatLimit = 40
|
export const chatLimit = 20
|
||||||
export const chatLimitHalf = 20
|
export const chatLimitHalf = 10
|
||||||
|
|
||||||
export const totalMsgCount = 120
|
export const totalMsgCount = 60
|
||||||
class ChatPage extends LitElement {
|
class ChatPage extends LitElement {
|
||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
@ -2810,6 +2810,14 @@ class ChatPage extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getOldMessage(scrollElement) {
|
async getOldMessage(scrollElement) {
|
||||||
|
if(!scrollElement || !scrollElement.messageObj || !scrollElement.messageObj.timestamp){
|
||||||
|
this.messagesRendered = {
|
||||||
|
messages: [],
|
||||||
|
type: 'old',
|
||||||
|
el: scrollElement
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
if (this.isReceipient) {
|
if (this.isReceipient) {
|
||||||
const getInitialMessages = await parentEpml.request('apiCall', {
|
const getInitialMessages = await parentEpml.request('apiCall', {
|
||||||
type: 'api',
|
type: 'api',
|
||||||
@ -2910,6 +2918,13 @@ class ChatPage extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async getAfterMessages(scrollElement) {
|
async getAfterMessages(scrollElement) {
|
||||||
|
if(!scrollElement || !scrollElement.messageObj || !scrollElement.messageObj.timestamp){
|
||||||
|
this.messagesRendered = {
|
||||||
|
messages: [],
|
||||||
|
type: 'new',
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
const timestamp = scrollElement.messageObj.timestamp
|
const timestamp = scrollElement.messageObj.timestamp
|
||||||
|
|
||||||
if (this.isReceipient) {
|
if (this.isReceipient) {
|
||||||
|
@ -260,7 +260,6 @@ export const chatStyles = css`
|
|||||||
.message-parent {
|
.message-parent {
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
background: rgba(245, 245, 245, 0);
|
background: rgba(245, 245, 245, 0);
|
||||||
transition: all 0.1s ease-in-out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-parent:hover {
|
.message-parent:hover {
|
||||||
@ -368,7 +367,6 @@ export const chatStyles = css`
|
|||||||
background:#fff;
|
background:#fff;
|
||||||
color: #000;
|
color: #000;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px;
|
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
z-index: 5;
|
z-index: 5;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
@ -414,7 +412,6 @@ export const chatStyles = css`
|
|||||||
width: 150px;
|
width: 150px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
padding: 3px 8px;
|
padding: 3px 8px;
|
||||||
box-shadow: rgba(77, 77, 82, 0.2) 0px 7px 29px 0px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.block-user:hover {
|
.block-user:hover {
|
||||||
|
@ -593,6 +593,7 @@ class ChatScroller extends LitElement {
|
|||||||
async updated(changedProperties) {
|
async updated(changedProperties) {
|
||||||
if (changedProperties && changedProperties.has('messages')) {
|
if (changedProperties && changedProperties.has('messages')) {
|
||||||
if (this.messages.type === 'initial') {
|
if (this.messages.type === 'initial') {
|
||||||
|
|
||||||
this.addNewMessages(this.messages.messages, 'initial')
|
this.addNewMessages(this.messages.messages, 'initial')
|
||||||
|
|
||||||
|
|
||||||
@ -1118,6 +1119,12 @@ class MessageTemplate extends LitElement {
|
|||||||
if (changedProperties.has('messageObj')) {
|
if (changedProperties.has('messageObj')) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if(changedProperties.has('showBlockAddressIcon')){
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if(changedProperties.has('openDialogBlockUser')){
|
||||||
|
return true
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1130,7 +1137,6 @@ class MessageTemplate extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
const hidemsg = this.hideMessages
|
const hidemsg = this.hideMessages
|
||||||
let message = ""
|
let message = ""
|
||||||
let messageVersion2 = ""
|
let messageVersion2 = ""
|
||||||
|
@ -99,211 +99,136 @@ export class TipUser extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async sendQort() {
|
async sendQort() {
|
||||||
const amount = this.shadowRoot.getElementById("amountInput").value
|
const amount = this.shadowRoot.getElementById("amountInput").value;
|
||||||
let recipient = this.userName
|
const recipient = this.userName;
|
||||||
this.sendMoneyLoading = true
|
|
||||||
this.btnDisable = true
|
|
||||||
|
|
||||||
if (parseFloat(amount) + parseFloat(0.011) > parseFloat(this.walletBalance)) {
|
this.sendMoneyLoading = true;
|
||||||
this.sendMoneyLoading = false
|
this.btnDisable = true;
|
||||||
this.btnDisable = false
|
|
||||||
let snack1string = get("chatpage.cchange51")
|
|
||||||
parentEpml.request('showSnackBar', `${snack1string}`)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parseFloat(amount) <= 0) {
|
// Helper function to reset loading and button state
|
||||||
this.sendMoneyLoading = false
|
const resetState = () => {
|
||||||
this.btnDisable = false
|
this.sendMoneyLoading = false;
|
||||||
let snack2string = get("chatpage.cchange52")
|
this.btnDisable = false;
|
||||||
parentEpml.request('showSnackBar', `${snack2string}`)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (recipient.length === 0) {
|
|
||||||
this.sendMoneyLoading = false
|
|
||||||
this.btnDisable = false
|
|
||||||
let snack3string = get("chatpage.cchange53")
|
|
||||||
parentEpml.request('showSnackBar', `${snack3string}`)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
const validateName = async (receiverName) => {
|
|
||||||
let myRes
|
|
||||||
let myNameRes = await parentEpml.request('apiCall', {
|
|
||||||
type: 'api',
|
|
||||||
url: `/names/${receiverName}`,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (myNameRes.error === 401) {
|
|
||||||
myRes = false
|
|
||||||
} else {
|
|
||||||
myRes = myNameRes
|
|
||||||
}
|
|
||||||
return myRes
|
|
||||||
}
|
|
||||||
|
|
||||||
const validateAddress = async (receiverAddress) => {
|
|
||||||
let myAddress = await window.parent.validateAddress(receiverAddress)
|
|
||||||
return myAddress
|
|
||||||
}
|
|
||||||
|
|
||||||
const validateReceiver = async (recipient) => {
|
|
||||||
let lastRef = await this.getLastRef()
|
|
||||||
let theFee = await this.getSendQortFee()
|
|
||||||
let isAddress
|
|
||||||
|
|
||||||
try {
|
|
||||||
isAddress = await validateAddress(recipient)
|
|
||||||
} catch (err) {
|
|
||||||
isAddress = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAddress) {
|
if (parseFloat(amount) + parseFloat(0.011) > parseFloat(this.walletBalance)) {
|
||||||
let myTransaction = await makeTransactionRequest(recipient, lastRef, theFee)
|
resetState();
|
||||||
getTxnRequestResponse(myTransaction)
|
const snack1string = get("chatpage.cchange51");
|
||||||
} else {
|
parentEpml.request('showSnackBar', `${snack1string}`);
|
||||||
let myNameRes = await validateName(recipient)
|
return false;
|
||||||
if (myNameRes !== false) {
|
|
||||||
let myNameAddress = myNameRes.owner
|
|
||||||
let myTransaction = await makeTransactionRequest(myNameAddress, lastRef, theFee)
|
|
||||||
getTxnRequestResponse(myTransaction)
|
|
||||||
} else {
|
|
||||||
let myNameRes = await validateName(recipient)
|
|
||||||
if (myNameRes !== false) {
|
|
||||||
let myNameAddress = myNameRes.owner
|
|
||||||
let myTransaction = await makeTransactionRequest(myNameAddress, lastRef)
|
|
||||||
getTxnRequestResponse(myTransaction)
|
|
||||||
} else {
|
|
||||||
console.error(this.renderReceiverText())
|
|
||||||
this.errorMessage = this.renderReceiverText()
|
|
||||||
this.sendMoneyLoading = false
|
|
||||||
this.btnDisable = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parseFloat(amount) <= 0) {
|
||||||
|
resetState();
|
||||||
|
const snack2string = get("chatpage.cchange52");
|
||||||
|
parentEpml.request('showSnackBar', `${snack2string}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recipient.length === 0) {
|
||||||
|
resetState();
|
||||||
|
const snack3string = get("chatpage.cchange53");
|
||||||
|
parentEpml.request('showSnackBar', `${snack3string}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const validateName = async (receiverName) => {
|
||||||
|
const myNameRes = await parentEpml.request('apiCall', {
|
||||||
|
type: 'api',
|
||||||
|
url: `/names/${receiverName}`
|
||||||
|
});
|
||||||
|
return myNameRes.error === 401 ? false : myNameRes;
|
||||||
|
};
|
||||||
|
|
||||||
|
const validateAddress = async (receiverAddress) => {
|
||||||
|
return await window.parent.validateAddress(receiverAddress);
|
||||||
|
};
|
||||||
|
|
||||||
const getName = async (recipient) => {
|
const getName = async (recipient) => {
|
||||||
try {
|
try {
|
||||||
const getNames = await parentEpml.request("apiCall", {
|
const getNames = await parentEpml.request("apiCall", {
|
||||||
type: "api",
|
type: "api",
|
||||||
url: `/names/address/${recipient}`,
|
url: `/names/address/${recipient}`
|
||||||
});
|
});
|
||||||
|
return getNames?.length > 0 ? getNames[0].name : '';
|
||||||
if (getNames?.length > 0) {
|
|
||||||
return getNames[0].name
|
|
||||||
} else {
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return ""
|
return "";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const makeTransactionRequest = async (receiver, lastRef) => {
|
const makeTransactionRequest = async (receiver, lastRef) => {
|
||||||
let myReceiver = receiver
|
const dialogAmount = get("transactions.amount");
|
||||||
let mylastRef = lastRef
|
const dialogAddress = get("login.address");
|
||||||
let dialogamount = get("transactions.amount")
|
const dialogName = get("login.name");
|
||||||
let dialogAddress = get("login.address")
|
const dialogTo = get("transactions.to");
|
||||||
let dialogName = get("login.name")
|
const recipientName = await getName(receiver);
|
||||||
let dialogto = get("transactions.to")
|
|
||||||
let recipientName = await getName(myReceiver)
|
return await parentEpml.request('transaction', {
|
||||||
let myTxnrequest = await parentEpml.request('transaction', {
|
|
||||||
type: 2,
|
type: 2,
|
||||||
nonce: this.myAddress.nonce,
|
nonce: this.myAddress.nonce,
|
||||||
params: {
|
params: {
|
||||||
recipient: myReceiver,
|
recipient: receiver,
|
||||||
recipientName: recipientName,
|
recipientName: recipientName,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
lastReference: mylastRef,
|
lastReference: lastRef,
|
||||||
fee: 0.001,
|
fee: this.qortPaymentFee,
|
||||||
dialogamount: dialogamount,
|
dialogAmount,
|
||||||
dialogto: dialogto,
|
dialogTo,
|
||||||
dialogAddress,
|
dialogAddress,
|
||||||
dialogName
|
dialogName
|
||||||
},
|
}
|
||||||
})
|
});
|
||||||
return myTxnrequest
|
};
|
||||||
}
|
|
||||||
|
|
||||||
const getTxnRequestResponse = (txnResponse) => {
|
const getTxnRequestResponse = (txnResponse) => {
|
||||||
if (txnResponse.success === false && txnResponse.message) {
|
if (txnResponse.success === false && txnResponse.message) {
|
||||||
this.errorMessage = txnResponse.message
|
this.errorMessage = txnResponse.message;
|
||||||
this.sendMoneyLoading = false
|
resetState();
|
||||||
this.btnDisable = false
|
throw new Error(txnResponse);
|
||||||
throw new Error(txnResponse)
|
|
||||||
} else if (txnResponse.success === true && !txnResponse.data.error) {
|
} else if (txnResponse.success === true && !txnResponse.data.error) {
|
||||||
this.shadowRoot.getElementById('amountInput').value = ''
|
this.shadowRoot.getElementById('amountInput').value = '';
|
||||||
this.errorMessage = ''
|
this.errorMessage = '';
|
||||||
this.successMessage = this.renderSuccessText()
|
this.successMessage = this.renderSuccessText();
|
||||||
this.sendMoneyLoading = false
|
resetState();
|
||||||
this.btnDisable = false
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.setOpenTipUser(false)
|
this.setOpenTipUser(false);
|
||||||
this.successMessage = ""
|
this.successMessage = "";
|
||||||
}, 3000)
|
}, 3000);
|
||||||
} else {
|
} else {
|
||||||
this.errorMessage = txnResponse.data.message
|
this.errorMessage = txnResponse.data.message;
|
||||||
this.sendMoneyLoading = false
|
resetState();
|
||||||
this.btnDisable = false
|
throw new Error(txnResponse);
|
||||||
throw new Error(txnResponse)
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
validateReceiver(recipient)
|
|
||||||
|
const validateReceiver = async (recipient) => {
|
||||||
|
let lastRef = await this.getLastRef();
|
||||||
|
let isAddress;
|
||||||
|
|
||||||
|
try {
|
||||||
|
isAddress = await validateAddress(recipient);
|
||||||
|
} catch (err) {
|
||||||
|
isAddress = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAddress) {
|
||||||
|
const myTransaction = await makeTransactionRequest(recipient, lastRef);
|
||||||
|
getTxnRequestResponse(myTransaction);
|
||||||
|
} else {
|
||||||
|
const myNameRes = await validateName(recipient);
|
||||||
|
if (myNameRes !== false) {
|
||||||
|
const myTransaction = await makeTransactionRequest(myNameRes.owner, lastRef);
|
||||||
|
getTxnRequestResponse(myTransaction);
|
||||||
|
} else {
|
||||||
|
this.errorMessage = this.renderReceiverText();
|
||||||
|
resetState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
await validateReceiver(recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
const makeTransactionRequest = async (receiver, lastRef, theFee) => {
|
|
||||||
let myReceiver = receiver
|
|
||||||
let mylastRef = lastRef
|
|
||||||
let myFee = theFee
|
|
||||||
let dialogamount = get("transactions.amount")
|
|
||||||
let dialogAddress = get("login.address")
|
|
||||||
let dialogName = get("login.name")
|
|
||||||
let dialogto = get("transactions.to")
|
|
||||||
let recipientName = await getName(myReceiver)
|
|
||||||
let myTxnrequest = await parentEpml.request('transaction', {
|
|
||||||
type: 2,
|
|
||||||
nonce: this.myAddress.nonce,
|
|
||||||
params: {
|
|
||||||
recipient: myReceiver,
|
|
||||||
recipientName: recipientName,
|
|
||||||
amount: amount,
|
|
||||||
lastReference: mylastRef,
|
|
||||||
fee: myFee,
|
|
||||||
dialogamount: dialogamount,
|
|
||||||
dialogto: dialogto,
|
|
||||||
dialogAddress,
|
|
||||||
dialogName
|
|
||||||
},
|
|
||||||
})
|
|
||||||
return myTxnrequest
|
|
||||||
}
|
|
||||||
|
|
||||||
const getTxnRequestResponse = (txnResponse) => {
|
|
||||||
if (txnResponse.success === false && txnResponse.message) {
|
|
||||||
this.errorMessage = txnResponse.message
|
|
||||||
this.sendMoneyLoading = false
|
|
||||||
this.btnDisable = false
|
|
||||||
throw new Error(txnResponse)
|
|
||||||
} else if (txnResponse.success === true && !txnResponse.data.error) {
|
|
||||||
this.shadowRoot.getElementById('amountInput').value = ''
|
|
||||||
this.errorMessage = ''
|
|
||||||
this.successMessage = this.renderSuccessText()
|
|
||||||
this.sendMoneyLoading = false
|
|
||||||
this.btnDisable = false
|
|
||||||
setTimeout(() => {
|
|
||||||
this.setOpenTipUser(false)
|
|
||||||
this.successMessage = ""
|
|
||||||
}, 3000)
|
|
||||||
} else {
|
|
||||||
this.errorMessage = txnResponse.data.message
|
|
||||||
this.sendMoneyLoading = false
|
|
||||||
this.btnDisable = false
|
|
||||||
throw new Error(txnResponse)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
validateReceiver(recipient)
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return html`
|
return html`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user