Browse Source

Fix unread replies status on empty threads

Fix clearing chat after it is closed
Fix bubbles loadedAll
master
Eduard Kuzmenko 3 years ago
parent
commit
b255c746fe
  1. 4
      src/components/chat/bubbles.ts
  2. 4
      src/components/chat/chat.ts
  3. 12
      src/components/chat/replies.ts
  4. 2
      src/config/app.ts
  5. 4
      src/lib/appManagers/appImManager.ts
  6. 16
      src/lib/appManagers/appMessagesManager.ts

4
src/components/chat/bubbles.ts

@ -2684,11 +2684,11 @@ export default class ChatBubbles {
const historyStorage = this.appMessagesManager.getHistoryStorage(this.peerId, this.chat.threadId); const historyStorage = this.appMessagesManager.getHistoryStorage(this.peerId, this.chat.threadId);
const firstSlice = historyStorage.history.first; const firstSlice = historyStorage.history.first;
const lastSlice = historyStorage.history.last; const lastSlice = historyStorage.history.last;
if(firstSlice.isEnd(SliceEnd.Bottom) && history.includes(firstSlice[0])) { if(firstSlice.isEnd(SliceEnd.Bottom) && (!firstSlice.length || history.includes(firstSlice[0]))) {
this.scrollable.loadedAll.bottom = true; this.scrollable.loadedAll.bottom = true;
} }
if(lastSlice.isEnd(SliceEnd.Top) && history.includes(lastSlice[lastSlice.length - 1])) { if(lastSlice.isEnd(SliceEnd.Top) && (!lastSlice.length || history.includes(lastSlice[lastSlice.length - 1]))) {
this.scrollable.loadedAll.top = true; this.scrollable.loadedAll.top = true;
} }

4
src/components/chat/chat.ts

@ -197,6 +197,10 @@ export default class Chat extends EventListenerBase<{
}); });
} }
public beforeDestroy() {
this.bubbles.cleanup();
}
public destroy() { public destroy() {
//const perf = performance.now(); //const perf = performance.now();

12
src/components/chat/replies.ts

@ -116,11 +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);
let isUnread: boolean; let isUnread = false;
if(replies.read_max_id !== undefined && replies.max_id !== undefined) { if(replies.replies) {
isUnread = replies.read_max_id < replies.max_id; if(replies.read_max_id !== undefined && replies.max_id !== undefined) {
} else { isUnread = replies.read_max_id < replies.max_id;
isUnread = !historyStorage.readMaxId || historyStorage.readMaxId < (replies.max_id || 0); } else {
isUnread = !historyStorage.readMaxId || historyStorage.readMaxId < (replies.max_id || 0);
}
} }
this.classList.toggle('is-unread', isUnread); this.classList.toggle('is-unread', isUnread);
} }

2
src/config/app.ts

@ -12,7 +12,7 @@
const App = { const App = {
id: 1025907, id: 1025907,
hash: '452b0359b988148995f22ff0f4229750', hash: '452b0359b988148995f22ff0f4229750',
version: '0.5.1', version: '0.5.2',
langPackVersion: '0.1.6', langPackVersion: '0.1.6',
langPack: 'macos', langPack: 'macos',
langPackCode: 'en', langPackCode: 'en',

4
src/lib/appManagers/appImManager.ts

@ -773,6 +773,10 @@ export class AppImManager {
appSidebarRight.sharedMediaTab.loadSidebarMedia(false); appSidebarRight.sharedMediaTab.loadSidebarMedia(false);
}); */ }); */
} }
spliced.forEach(chat => {
chat.beforeDestroy();
});
setTimeout(() => { setTimeout(() => {
//chat.setPeer(0); //chat.setPeer(0);

16
src/lib/appManagers/appMessagesManager.ts

@ -4654,16 +4654,14 @@ export class AppMessagesManager {
mids.splice(i, 0, offset_id); mids.splice(i, 0, offset_id);
} }
const slice = historyStorage.history.insertSlice(mids); const slice = historyStorage.history.insertSlice(mids) || historyStorage.history.slice;
if(slice) { if(isTopEnd) {
if(isTopEnd) { slice.setEnd(SliceEnd.Top);
slice.setEnd(SliceEnd.Top); }
}
if(isBottomEnd) { if(isBottomEnd) {
slice.setEnd(SliceEnd.Bottom); slice.setEnd(SliceEnd.Bottom);
historyStorage.maxId = slice[0]; // ! WARNING historyStorage.maxId = slice[0]; // ! WARNING
}
} }
/* const isBackLimit = offset < 0 && -offset !== fullLimit; /* const isBackLimit = offset < 0 && -offset !== fullLimit;

Loading…
Cancel
Save