4
1
mirror of https://github.com/Qortal/qortal-ui.git synced 2025-02-12 02:05:51 +00:00

add loader to goToReply

This commit is contained in:
Phillip 2023-01-30 00:27:02 +02:00
parent 9ca90ef963
commit a19eea4ad7
2 changed files with 54 additions and 12 deletions

View File

@ -103,7 +103,8 @@ class ChatPage extends LitElement {
openUserInfo: { type: Boolean }, openUserInfo: { type: Boolean },
selectedHead: { type: Object }, selectedHead: { type: Object },
userName: { type: String }, userName: { type: String },
goToRepliedMessage: {attribute: false} goToRepliedMessage: {attribute: false},
isLoadingGoToRepliedMessage: {type: Object}
} }
} }
@ -890,6 +891,12 @@ class ChatPage extends LitElement {
this.currentEditor = '_chatEditorDOM' this.currentEditor = '_chatEditorDOM'
this.initialChat = this.initialChat.bind(this) this.initialChat = this.initialChat.bind(this)
this.isEnabledChatEnter = true this.isEnabledChatEnter = true
this.isLoadingGoToRepliedMessage = {
isLoading: false,
top: 0,
left: 0,
offsetHeight: 0
}
} }
_toggle(value) { _toggle(value) {
@ -957,6 +964,9 @@ class ChatPage extends LitElement {
` : ` :
this.renderChatScroller()} this.renderChatScroller()}
</div> </div>
${this.isLoadingGoToRepliedMessage && this.isLoadingGoToRepliedMessage.loading ? html`
<div style="position: fixed; top:${parseInt(this.isLoadingGoToRepliedMessage.top)}px;left: ${parseInt(this.isLoadingGoToRepliedMessage.left)}px" class=${`smallLoading marginLoader`}></div>
` : ''}
<div class="chat-text-area" style="${`${(this.repliedToMessageObj || this.editedMessageObj) && "min-height: 120px"}`}"> <div class="chat-text-area" style="${`${(this.repliedToMessageObj || this.editedMessageObj) && "min-height: 120px"}`}">
<div <div
@ -1417,10 +1427,19 @@ class ChatPage extends LitElement {
this.webSocket.close(1000, 'switch chat') this.webSocket.close(1000, 'switch chat')
this.webSocket= '' this.webSocket= ''
} }
this.webWorker.terminate(); if(this.webWorker){
this.webWorkerImage.terminate(); this.webWorker.terminate();
this.editor.destroy() }
this.editorImage.destroy() if(this.webWorkerImage){
this.webWorkerImage.terminate();
}
if(this.editor){
this.editor.destroy()
}
if(this.editorImage){
this.editorImage.destroy()
}
document.removeEventListener('keydown', this.initialChat); document.removeEventListener('keydown', this.initialChat);
} }
@ -1436,11 +1455,12 @@ class ChatPage extends LitElement {
} }
} }
} }
async goToRepliedMessage(message){ async goToRepliedMessage(message, clickedOnMessage){
const findMessage = this.shadowRoot.querySelector('chat-scroller').shadowRoot.getElementById(message.reference) const findMessage = this.shadowRoot.querySelector('chat-scroller').shadowRoot.getElementById(message.reference)
if(findMessage){ if(findMessage){
findMessage.scrollIntoView({ behavior: 'smooth', block: 'center' }) findMessage.scrollIntoView({ behavior: 'smooth', block: 'center' })
const findElement = findMessage.shadowRoot.querySelector('.message-parent') const findElement = findMessage.shadowRoot.querySelector('.message-parent')
@ -1459,11 +1479,30 @@ class ChatPage extends LitElement {
return return
} }
if((message.timestamp - this.messagesRendered[0].timestamp) < 86400000){ if((message.timestamp - this.messagesRendered[0].timestamp) < 86400000){
const findOriginalMessage = this.shadowRoot.querySelector('chat-scroller').shadowRoot.getElementById(clickedOnMessage.reference)
console.log({clickedOnMessage, findOriginalMessage})
if(findOriginalMessage){
const messageClientRect = findOriginalMessage.getBoundingClientRect()
this.isLoadingGoToRepliedMessage = {
...this.isLoadingGoToRepliedMessage,
loading: true,
left: messageClientRect.left,
top: messageClientRect.top,
offsetHeight: findOriginalMessage.offsetHeight
}
}
await this.getOldMessageDynamic(0, this.messagesRendered[0].timestamp, message.timestamp - 7200000) await this.getOldMessageDynamic(0, this.messagesRendered[0].timestamp, message.timestamp - 7200000)
const findMessage = this.shadowRoot.querySelector('chat-scroller').shadowRoot.getElementById(message.reference) const findMessage = this.shadowRoot.querySelector('chat-scroller').shadowRoot.getElementById(message.reference)
if(findMessage){ if(findMessage){
findMessage.scrollIntoView({ behavior: 'smooth', block: 'center' }) this.isLoadingGoToRepliedMessage = {
...this.isLoadingGoToRepliedMessage,
loading: false
}
findMessage.scrollIntoView({block: 'center' })
const findElement = findMessage.shadowRoot.querySelector('.message-parent') const findElement = findMessage.shadowRoot.querySelector('.message-parent')
if(findElement){ if(findElement){
findElement.classList.add('blink-bg') findElement.classList.add('blink-bg')
@ -1471,10 +1510,13 @@ class ChatPage extends LitElement {
findElement.classList.remove('blink-bg') findElement.classList.remove('blink-bg')
}, 2000) }, 2000)
} }
return return
} }
this.isLoadingGoToRepliedMessage = {
...this.isLoadingGoToRepliedMessage,
loading: false
}
let errorMsg = get("chatpage.cchange66") let errorMsg = get("chatpage.cchange66")
parentEpml.request('showSnackBar', `${errorMsg}`) parentEpml.request('showSnackBar', `${errorMsg}`)
@ -1784,7 +1826,7 @@ class ChatPage extends LitElement {
.setSelectedHead=${(val) => this.setSelectedHead(val)} .setSelectedHead=${(val) => this.setSelectedHead(val)}
?openTipUser=${this.openTipUser} ?openTipUser=${this.openTipUser}
.selectedHead=${this.selectedHead} .selectedHead=${this.selectedHead}
.goToRepliedMessage=${(val)=> this.goToRepliedMessage(val)} .goToRepliedMessage=${(val, val2)=> this.goToRepliedMessage(val, val2)}
.getOldMessageAfter=${(val)=> this.getOldMessageAfter(val)} .getOldMessageAfter=${(val)=> this.getOldMessageAfter(val)}
> >
</chat-scroller> </chat-scroller>

View File

@ -554,7 +554,7 @@ class MessageTemplate extends LitElement {
${repliedToData && html` ${repliedToData && html`
<div class="original-message" <div class="original-message"
@click=${()=> { @click=${()=> {
this.goToRepliedMessage(repliedToData) this.goToRepliedMessage(repliedToData, this.messageObj)
}}> }}>
<p <p
style=${"cursor: pointer; margin: 0 0 5px 0;"} style=${"cursor: pointer; margin: 0 0 5px 0;"}