From c2a7d1bd8f7203cf2686f6e8d5a9e974bde76bdb Mon Sep 17 00:00:00 2001 From: morethanwords Date: Sat, 8 May 2021 15:31:12 +0400 Subject: [PATCH] temp --- src/components/chat/bubbles.ts | 32 +++++++++++------------ src/components/chat/replies.ts | 8 +++++- src/lib/appManagers/appMessagesManager.ts | 8 +++--- src/scss/partials/_chatBubble.scss | 4 +++ 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/components/chat/bubbles.ts b/src/components/chat/bubbles.ts index 671e0f3e..4e923cb6 100644 --- a/src/components/chat/bubbles.ts +++ b/src/components/chat/bubbles.ts @@ -1440,9 +1440,9 @@ export default class ChatBubbles { const isTarget = lastMsgId !== undefined; // * this one will fix topMessage for null message in history (e.g. channel comments with only 1 comment and it is a topMessage) - if(this.chat.type !== 'pinned' && topMessage && !historyStorage.history.slice.includes(topMessage)) { + /* if(this.chat.type !== 'pinned' && topMessage && !historyStorage.history.slice.includes(topMessage)) { topMessage = 0; - } + } */ let readMaxId = 0, savedPosition: ReturnType; if(!isTarget) { @@ -1653,7 +1653,7 @@ export default class ChatBubbles { const slice = historyStorage.history.slice; const isBottomEnd = slice.isEnd(SliceEnd.Bottom); - if(this.scrollable.loadedAll.bottom !== isBottomEnd) { + if(this.scrollable.loadedAll.bottom && this.scrollable.loadedAll.bottom !== isBottomEnd) { this.scrollable.loadedAll.bottom = isBottomEnd; this.onScroll(); } @@ -2622,19 +2622,19 @@ export default class ChatBubbles { public performHistoryResult(history: number[], reverse: boolean, isBackLimit: boolean, additionMsgId?: number) { // commented bot getProfile in getHistory! - if(!history/* .filter((id: number) => id > 0) */.length) { - if(!isBackLimit) { - this.scrollable.loadedAll.top = true; - - /* if(this.chat.type === 'discussion') { - const serviceStartMessageId = this.appMessagesManager.threadsServiceMessagesIdsStorage[this.peerId + '_' + this.chat.threadId]; - if(serviceStartMessageId) history.push(serviceStartMessageId); - history.push(this.chat.threadId); - } */ - } else { - this.scrollable.loadedAll.bottom = true; - } - } + // if(!history/* .filter((id: number) => id > 0) */.length) { + // if(!isBackLimit) { + // this.scrollable.loadedAll.top = true; + + // /* if(this.chat.type === 'discussion') { + // const serviceStartMessageId = this.appMessagesManager.threadsServiceMessagesIdsStorage[this.peerId + '_' + this.chat.threadId]; + // if(serviceStartMessageId) history.push(serviceStartMessageId); + // history.push(this.chat.threadId); + // } */ + // } else { + // this.scrollable.loadedAll.bottom = true; + // } + // } history = history.slice(); // need diff --git a/src/components/chat/replies.ts b/src/components/chat/replies.ts index 340e1686..177dabb2 100644 --- a/src/components/chat/replies.ts +++ b/src/components/chat/replies.ts @@ -116,7 +116,13 @@ export default class RepliesElement extends HTMLElement { if(replies) { const historyStorage = appMessagesManager.getHistoryStorage(-replies.channel_id); - this.classList.toggle('is-unread', replies.read_max_id < replies.max_id && (!historyStorage.readMaxId || historyStorage.readMaxId < replies.max_id)); + let isUnread: boolean; + if(replies.read_max_id !== undefined && replies.max_id !== undefined) { + isUnread = replies.read_max_id < replies.max_id; + } else { + isUnread = !historyStorage.readMaxId || historyStorage.readMaxId < (replies.max_id || 0); + } + this.classList.toggle('is-unread', isUnread); } let textSpan = this.children[1] as HTMLElement; diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index 77ce0277..cf019688 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -1599,8 +1599,8 @@ export class AppMessagesManager { const historyStorage = this.getHistoryStorage(peerId, threadId); if(threadId) { const chatHistoryStorage = this.getHistoryStorage(peerId); - const readMaxId = Math.max(chatHistoryStorage.readMaxId, historyStorage.readMaxId); - const message = this.getMessageByPeer(peerId, historyStorage.maxId); + const readMaxId = Math.max(chatHistoryStorage.readMaxId ?? 0, historyStorage.readMaxId); + const message = this.getMessageByPeer(peerId, historyStorage.maxId); // usually message is missing, so pFlags.out won't be there anyway return !message.pFlags.out && readMaxId < historyStorage.maxId ? readMaxId : 0; } else { const message = this.getMessageByPeer(peerId, historyStorage.maxId); @@ -3286,7 +3286,7 @@ export class AppMessagesManager { const historyStorage = this.getHistoryStorage(message.peerId, message.mid); result.max_id = historyStorage.maxId = this.generateMessageId(result.max_id) || 0; - result.read_inbox_max_id = historyStorage.readMaxId = this.generateMessageId(result.read_inbox_max_id) || 0; + result.read_inbox_max_id = historyStorage.readMaxId = this.generateMessageId(result.read_inbox_max_id ?? message.mid); result.read_outbox_max_id = historyStorage.readOutboxMaxId = this.generateMessageId(result.read_outbox_max_id) || 0; this.threadsToReplies[threadKey] = peerId + '_' + mid; @@ -3417,7 +3417,7 @@ export class AppMessagesManager { // TODO: cancel notification by peer when this function is being called public readHistory(peerId: number, maxId = 0, threadId?: number, force = false) { - //return Promise.resolve(); + return Promise.resolve(); // console.trace('start read') this.log('readHistory:', peerId, maxId, threadId); if(!this.getReadMaxIdIfUnread(peerId, threadId) && !force) { diff --git a/src/scss/partials/_chatBubble.scss b/src/scss/partials/_chatBubble.scss index e8b310b2..4aa15226 100644 --- a/src/scss/partials/_chatBubble.scss +++ b/src/scss/partials/_chatBubble.scss @@ -1216,6 +1216,10 @@ $bubble-margin: .25rem; white-space: nowrap; height: 18px; + &:after { + color: #fff; + } + .inner { display: none; }