Browse Source

temp

master
morethanwords 3 years ago
parent
commit
c2a7d1bd8f
  1. 32
      src/components/chat/bubbles.ts
  2. 8
      src/components/chat/replies.ts
  3. 8
      src/lib/appManagers/appMessagesManager.ts
  4. 4
      src/scss/partials/_chatBubble.scss

32
src/components/chat/bubbles.ts

@ -1440,9 +1440,9 @@ export default class ChatBubbles {
const isTarget = lastMsgId !== undefined; 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) // * 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; topMessage = 0;
} } */
let readMaxId = 0, savedPosition: ReturnType<AppImManager['getChatSavedPosition']>; let readMaxId = 0, savedPosition: ReturnType<AppImManager['getChatSavedPosition']>;
if(!isTarget) { if(!isTarget) {
@ -1653,7 +1653,7 @@ export default class ChatBubbles {
const slice = historyStorage.history.slice; const slice = historyStorage.history.slice;
const isBottomEnd = slice.isEnd(SliceEnd.Bottom); 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.scrollable.loadedAll.bottom = isBottomEnd;
this.onScroll(); this.onScroll();
} }
@ -2622,19 +2622,19 @@ export default class ChatBubbles {
public performHistoryResult(history: number[], reverse: boolean, isBackLimit: boolean, additionMsgId?: number) { public performHistoryResult(history: number[], reverse: boolean, isBackLimit: boolean, additionMsgId?: number) {
// commented bot getProfile in getHistory! // commented bot getProfile in getHistory!
if(!history/* .filter((id: number) => id > 0) */.length) { // if(!history/* .filter((id: number) => id > 0) */.length) {
if(!isBackLimit) { // if(!isBackLimit) {
this.scrollable.loadedAll.top = true; // this.scrollable.loadedAll.top = true;
/* if(this.chat.type === 'discussion') { // /* if(this.chat.type === 'discussion') {
const serviceStartMessageId = this.appMessagesManager.threadsServiceMessagesIdsStorage[this.peerId + '_' + this.chat.threadId]; // const serviceStartMessageId = this.appMessagesManager.threadsServiceMessagesIdsStorage[this.peerId + '_' + this.chat.threadId];
if(serviceStartMessageId) history.push(serviceStartMessageId); // if(serviceStartMessageId) history.push(serviceStartMessageId);
history.push(this.chat.threadId); // history.push(this.chat.threadId);
} */ // } */
} else { // } else {
this.scrollable.loadedAll.bottom = true; // this.scrollable.loadedAll.bottom = true;
} // }
} // }
history = history.slice(); // need history = history.slice(); // need

8
src/components/chat/replies.ts

@ -116,7 +116,13 @@ export default class RepliesElement extends HTMLElement {
if(replies) { if(replies) {
const historyStorage = appMessagesManager.getHistoryStorage(-replies.channel_id); 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; let textSpan = this.children[1] as HTMLElement;

8
src/lib/appManagers/appMessagesManager.ts

@ -1599,8 +1599,8 @@ export class AppMessagesManager {
const historyStorage = this.getHistoryStorage(peerId, threadId); const historyStorage = this.getHistoryStorage(peerId, threadId);
if(threadId) { if(threadId) {
const chatHistoryStorage = this.getHistoryStorage(peerId); const chatHistoryStorage = this.getHistoryStorage(peerId);
const readMaxId = Math.max(chatHistoryStorage.readMaxId, historyStorage.readMaxId); const readMaxId = Math.max(chatHistoryStorage.readMaxId ?? 0, historyStorage.readMaxId);
const message = this.getMessageByPeer(peerId, historyStorage.maxId); 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; return !message.pFlags.out && readMaxId < historyStorage.maxId ? readMaxId : 0;
} else { } else {
const message = this.getMessageByPeer(peerId, historyStorage.maxId); const message = this.getMessageByPeer(peerId, historyStorage.maxId);
@ -3286,7 +3286,7 @@ export class AppMessagesManager {
const historyStorage = this.getHistoryStorage(message.peerId, message.mid); const historyStorage = this.getHistoryStorage(message.peerId, message.mid);
result.max_id = historyStorage.maxId = this.generateMessageId(result.max_id) || 0; 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; result.read_outbox_max_id = historyStorage.readOutboxMaxId = this.generateMessageId(result.read_outbox_max_id) || 0;
this.threadsToReplies[threadKey] = peerId + '_' + mid; this.threadsToReplies[threadKey] = peerId + '_' + mid;
@ -3417,7 +3417,7 @@ export class AppMessagesManager {
// TODO: cancel notification by peer when this function is being called // TODO: cancel notification by peer when this function is being called
public readHistory(peerId: number, maxId = 0, threadId?: number, force = false) { public readHistory(peerId: number, maxId = 0, threadId?: number, force = false) {
//return Promise.resolve(); return Promise.resolve();
// console.trace('start read') // console.trace('start read')
this.log('readHistory:', peerId, maxId, threadId); this.log('readHistory:', peerId, maxId, threadId);
if(!this.getReadMaxIdIfUnread(peerId, threadId) && !force) { if(!this.getReadMaxIdIfUnread(peerId, threadId) && !force) {

4
src/scss/partials/_chatBubble.scss

@ -1216,6 +1216,10 @@ $bubble-margin: .25rem;
white-space: nowrap; white-space: nowrap;
height: 18px; height: 18px;
&:after {
color: #fff;
}
.inner { .inner {
display: none; display: none;
} }

Loading…
Cancel
Save