mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-04-23 11:27:52 +00:00
fix avatar issue
This commit is contained in:
parent
e07884c1e1
commit
fe9af1dc82
@ -108,9 +108,10 @@ class ChatHead extends LitElement {
|
|||||||
this.isImageLoaded = false
|
this.isImageLoaded = false
|
||||||
this.imageFetches = 0
|
this.imageFetches = 0
|
||||||
this.lastReadMessageTimestamp = 0
|
this.lastReadMessageTimestamp = 0
|
||||||
|
this.loggedInAddress = window.parent.reduxStore.getState().app.selectedAddress.address
|
||||||
}
|
}
|
||||||
|
|
||||||
createImage(imageUrl) {
|
createImage(imageUrl) {
|
||||||
const imageHTMLRes = new Image();
|
const imageHTMLRes = new Image();
|
||||||
imageHTMLRes.src = imageUrl;
|
imageHTMLRes.src = imageUrl;
|
||||||
imageHTMLRes.style= "width:40px; height:40px; float: left; border-radius:50%";
|
imageHTMLRes.style= "width:40px; height:40px; float: left; border-radius:50%";
|
||||||
@ -125,7 +126,7 @@ class ChatHead extends LitElement {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.imageFetches = this.imageFetches + 1;
|
this.imageFetches = this.imageFetches + 1;
|
||||||
imageHTMLRes.src = imageUrl;
|
imageHTMLRes.src = imageUrl;
|
||||||
}, 500);
|
}, 750);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
@ -134,9 +135,9 @@ class ChatHead extends LitElement {
|
|||||||
};
|
};
|
||||||
return imageHTMLRes;
|
return imageHTMLRes;
|
||||||
}
|
}
|
||||||
updated(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let avatarImg = '';
|
let avatarImg = '';
|
||||||
let backupAvatarImg = ''
|
let backupAvatarImg = ''
|
||||||
@ -158,7 +159,10 @@ class ChatHead extends LitElement {
|
|||||||
if(this.activeChatHeadUrl === this.chatInfo.url){
|
if(this.activeChatHeadUrl === this.chatInfo.url){
|
||||||
isUnread = false
|
isUnread = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.chatInfo.sender === this.loggedInAddress){
|
||||||
|
isUnread = false
|
||||||
|
}
|
||||||
return html`
|
return html`
|
||||||
<li @click=${() => this.getUrl(this.chatInfo.url)} class="clearfix ${this.activeChatHeadUrl === this.chatInfo.url ? 'active' : ''}">
|
<li @click=${() => this.getUrl(this.chatInfo.url)} class="clearfix ${this.activeChatHeadUrl === this.chatInfo.url ? 'active' : ''}">
|
||||||
${this.isImageLoaded ? html`${avatarImg}` : html`` }
|
${this.isImageLoaded ? html`${avatarImg}` : html`` }
|
||||||
@ -221,6 +225,14 @@ class ChatHead extends LitElement {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if(changedProperties.has('chatInfo')){
|
if(changedProperties.has('chatInfo')){
|
||||||
|
|
||||||
|
const prevChatInfo = changedProperties.get('chatInfo')
|
||||||
|
|
||||||
|
if(prevChatInfo.address !== this.chatInfo.address){
|
||||||
|
|
||||||
|
this.isImageLoaded = false
|
||||||
|
this.requestUpdate()
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import { Epml } from '../../../../epml.js';
|
|||||||
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate';
|
import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate';
|
||||||
import { qchatStyles } from './q-chat-css.src.js'
|
import { qchatStyles } from './q-chat-css.src.js'
|
||||||
import WebWorker from 'web-worker:./computePowWorker.src.js';
|
import WebWorker from 'web-worker:./computePowWorker.src.js';
|
||||||
|
import {repeat} from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
registerTranslateConfig({
|
registerTranslateConfig({
|
||||||
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
|
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
|
||||||
@ -856,14 +857,11 @@ class Chat extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderChatHead(chatHeadArr) {
|
renderChatHead(chatHeadArr) {
|
||||||
|
|
||||||
let tempUrl = document.location.href
|
|
||||||
let splitedUrl = decodeURI(tempUrl).split('?')
|
|
||||||
// let activeChatHeadUrl = splitedUrl[1] === undefined ? '' : splitedUrl[1]
|
|
||||||
|
|
||||||
return chatHeadArr.map(eachChatHead => {
|
return chatHeadArr.map(eachChatHead => {
|
||||||
return html`<chat-head activeChatHeadUrl=${this.activeChatHeadUrl} .setActiveChatHeadUrl=${(val)=> this.setActiveChatHeadUrl(val)} chatInfo=${JSON.stringify(eachChatHead)}></chat-head>`
|
return html`<chat-head activeChatHeadUrl=${this.activeChatHeadUrl} .setActiveChatHeadUrl=${(val)=> this.setActiveChatHeadUrl(val)} chatInfo=${JSON.stringify(eachChatHead)}></chat-head>`
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderChatPage() {
|
renderChatPage() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user