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 { @@ -2684,11 +2684,11 @@ export default class ChatBubbles {
const historyStorage = this.appMessagesManager.getHistoryStorage(this.peerId, this.chat.threadId);
const firstSlice = historyStorage.history.first;
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;
}
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;
}

4
src/components/chat/chat.ts

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

12
src/components/chat/replies.ts

@ -116,11 +116,13 @@ export default class RepliesElement extends HTMLElement { @@ -116,11 +116,13 @@ export default class RepliesElement extends HTMLElement {
if(replies) {
const historyStorage = appMessagesManager.getHistoryStorage(-replies.channel_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);
let isUnread = false;
if(replies.replies) {
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);
}

2
src/config/app.ts

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

4
src/lib/appManagers/appImManager.ts

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

16
src/lib/appManagers/appMessagesManager.ts

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

Loading…
Cancel
Save