|
|
|
@ -69,25 +69,22 @@ export namespace MessageRender {
@@ -69,25 +69,22 @@ export namespace MessageRender {
|
|
|
|
|
messageDiv: HTMLElement |
|
|
|
|
}) => { |
|
|
|
|
const isFooter = !bubble.classList.contains('sticker') && !bubble.classList.contains('emoji-big'); |
|
|
|
|
const repliesFooter = new RepliesFooterElement(); |
|
|
|
|
|
|
|
|
|
if(isFooter) { |
|
|
|
|
repliesFooter.message = message; |
|
|
|
|
repliesFooter.type = 'footer'; |
|
|
|
|
bubbleContainer.prepend(repliesFooter); |
|
|
|
|
} |
|
|
|
|
const repliesFooter = new RepliesElement(); |
|
|
|
|
repliesFooter.message = message; |
|
|
|
|
repliesFooter.type = isFooter ? 'footer' : 'beside'; |
|
|
|
|
bubbleContainer.prepend(repliesFooter); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rootScope.on('replies_updated', (e) => { |
|
|
|
|
const message = e.detail; |
|
|
|
|
(Array.from(document.querySelectorAll(`replies-footer-element[data-post-key="${message.peerId}_${message.mid}"]`)) as RepliesFooterElement[]).forEach(element => { |
|
|
|
|
(Array.from(document.querySelectorAll(`replies-footer-element[data-post-key="${message.peerId}_${message.mid}"]`)) as RepliesElement[]).forEach(element => { |
|
|
|
|
element.message = message; |
|
|
|
|
element.render(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
class RepliesFooterElement extends HTMLElement { |
|
|
|
|
class RepliesElement extends HTMLElement { |
|
|
|
|
public message: Message.message; |
|
|
|
|
public type: 'footer' | 'beside'; |
|
|
|
|
|
|
|
|
@ -95,46 +92,51 @@ class RepliesFooterElement extends HTMLElement {
@@ -95,46 +92,51 @@ class RepliesFooterElement extends HTMLElement {
|
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
|
super(); |
|
|
|
|
|
|
|
|
|
this.classList.add('replies-footer'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
connectedCallback() { |
|
|
|
|
this.render(); |
|
|
|
|
this.dataset.postKey = this.message.peerId + '_' + this.message.mid; |
|
|
|
|
this.classList.add('replies', 'replies-' + this.type); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public render() { |
|
|
|
|
const replies = this.message.replies; |
|
|
|
|
|
|
|
|
|
let leftHTML = '', lastStyle = ''; |
|
|
|
|
if(replies.recent_repliers) { |
|
|
|
|
leftHTML += '<div class="replies-footer-avatars">' |
|
|
|
|
/** |
|
|
|
|
* MACOS, ANDROID - без реверса |
|
|
|
|
* WINDOWS DESKTOP - реверс |
|
|
|
|
* все приложения накладывают аватарку первую на вторую, а в макете зато вторая на первую, ЛОЛ! |
|
|
|
|
*/ |
|
|
|
|
let l: string[] = []; |
|
|
|
|
replies.recent_repliers/* .slice().reverse() */.forEach((peer, idx) => { |
|
|
|
|
lastStyle = idx == 0 ? '' : `style="transform: translateX(-${idx * 12}px);"`; |
|
|
|
|
l.push(`<avatar-element class="avatar-32" dialog="0" peer="${appPeersManager.getPeerId(peer)}" ${lastStyle}></avatar-element>`); |
|
|
|
|
}); |
|
|
|
|
leftHTML += l.reverse().join('') + '</div>'; |
|
|
|
|
} else { |
|
|
|
|
leftHTML = '<span class="tgico-comments"></span>'; |
|
|
|
|
} |
|
|
|
|
if(this.type === 'footer') { |
|
|
|
|
let leftHTML = '', lastStyle = ''; |
|
|
|
|
if(replies.recent_repliers) { |
|
|
|
|
leftHTML += '<div class="replies-footer-avatars">' |
|
|
|
|
let l: string[] = []; |
|
|
|
|
replies.recent_repliers/* .slice().reverse() */.forEach((peer, idx) => { |
|
|
|
|
lastStyle = idx == 0 ? '' : `style="transform: translateX(-${idx * 12}px);"`; |
|
|
|
|
l.push(`<avatar-element class="avatar-32" dialog="0" peer="${appPeersManager.getPeerId(peer)}" ${lastStyle}></avatar-element>`); |
|
|
|
|
}); |
|
|
|
|
leftHTML += l.reverse().join('') + '</div>'; |
|
|
|
|
} else { |
|
|
|
|
leftHTML = '<span class="tgico-comments"></span>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let text: string; |
|
|
|
|
if(replies.replies) { |
|
|
|
|
text = replies.replies + ' ' + (replies.replies > 1 ? 'Comments' : 'Comment'); |
|
|
|
|
} else { |
|
|
|
|
text = 'Leave a Comment'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const historyStorage = appMessagesManager.getHistoryStorage(-replies.channel_id); |
|
|
|
|
if(replies.read_max_id < replies.max_id && (!historyStorage.readMaxId || historyStorage.readMaxId < replies.max_id)) { |
|
|
|
|
this.classList.add('is-unread'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.innerHTML = `${leftHTML}<span class="replies-footer-text" ${lastStyle}>${text}</span><span class="tgico-next"></span>`; |
|
|
|
|
|
|
|
|
|
let text: string; |
|
|
|
|
if(replies.replies) { |
|
|
|
|
text = replies.replies + ' ' + (replies.replies > 1 ? 'Comments' : 'Comment'); |
|
|
|
|
const rippleContainer = document.createElement('div'); |
|
|
|
|
this.append(rippleContainer); |
|
|
|
|
ripple(rippleContainer); |
|
|
|
|
} else { |
|
|
|
|
text = 'Leave a Comment'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const historyStorage = appMessagesManager.getHistoryStorage(-replies.channel_id); |
|
|
|
|
if(replies.read_max_id < replies.max_id && (!historyStorage.readMaxId || historyStorage.readMaxId < replies.max_id)) { |
|
|
|
|
this.classList.add('is-unread'); |
|
|
|
|
this.classList.add('bubble-beside-button'); |
|
|
|
|
this.innerHTML = `<span class="tgico-commentssticker"></span><span class="replies-beside-text">${formatNumber(replies.replies, 0) || ''}</span>`; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!this.updated) { |
|
|
|
@ -142,13 +144,7 @@ class RepliesFooterElement extends HTMLElement {
@@ -142,13 +144,7 @@ class RepliesFooterElement extends HTMLElement {
|
|
|
|
|
appMessagesManager.updateMessage(this.message.peerId, this.message.mid, 'replies_updated'); |
|
|
|
|
this.updated = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.innerHTML = `${leftHTML}<span class="replies-footer-text" ${lastStyle}>${text}</span><span class="tgico-next"></span>`; |
|
|
|
|
|
|
|
|
|
const rippleContainer = document.createElement('div'); |
|
|
|
|
this.append(rippleContainer); |
|
|
|
|
ripple(rippleContainer); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
customElements.define('replies-footer-element', RepliesFooterElement); |
|
|
|
|
customElements.define('replies-element', RepliesElement); |