Browse Source

Fix loading extra page of messages

Adjust load messages length
master
Eduard Kuzmenko 3 years ago
parent
commit
a3c6e4d365
  1. 13
      src/components/chat/bubbles.ts
  2. 2
      src/helpers/scrollSaver.ts

13
src/components/chat/bubbles.ts

@ -2418,7 +2418,7 @@ export default class ChatBubbles {
//if(dialog && lastMsgID && lastMsgID !== topMessage && (this.bubbles[lastMsgID] || this.firstUnreadBubble)) { //if(dialog && lastMsgID && lastMsgID !== topMessage && (this.bubbles[lastMsgID] || this.firstUnreadBubble)) {
if(savedPosition) { if(savedPosition) {
scrollable.scrollTop = savedPosition.top; scrollable.scrollTop = scrollable.lastScrollPosition = savedPosition.top;
/* const mountedByLastMsgId = this.getMountedBubble(lastMsgId); /* const mountedByLastMsgId = this.getMountedBubble(lastMsgId);
let bubble: HTMLElement = mountedByLastMsgId?.bubble; let bubble: HTMLElement = mountedByLastMsgId?.bubble;
if(!bubble?.parentElement) { if(!bubble?.parentElement) {
@ -2434,9 +2434,9 @@ export default class ChatBubbles {
const fromUp = maxBubbleId > 0 && (maxBubbleId < lastMsgId || lastMsgId < 0); const fromUp = maxBubbleId > 0 && (maxBubbleId < lastMsgId || lastMsgId < 0);
const followingUnread = readMaxId === lastMsgId && !isTarget; const followingUnread = readMaxId === lastMsgId && !isTarget;
if(!fromUp && samePeer) { if(!fromUp && samePeer) {
scrollable.scrollTop = 99999; scrollable.scrollTop = scrollable.lastScrollPosition = 99999;
} else if(fromUp/* && (samePeer || forwardingUnread) */) { } else if(fromUp/* && (samePeer || forwardingUnread) */) {
scrollable.scrollTop = 0; scrollable.scrollTop = scrollable.lastScrollPosition = 0;
} }
const mountedByLastMsgId = this.getMountedBubble(lastMsgId); const mountedByLastMsgId = this.getMountedBubble(lastMsgId);
@ -2453,7 +2453,7 @@ export default class ChatBubbles {
} }
} }
} else { } else {
scrollable.scrollTop = 99999; scrollable.scrollTop = scrollable.lastScrollPosition = 99999;
} }
this.onScroll(); this.onScroll();
@ -4463,10 +4463,11 @@ export default class ChatBubbles {
public getHistory(maxId = 0, reverse = false, isBackLimit = false, additionMsgId = 0, justLoad = false): {cached: boolean, promise: Promise<boolean>} { public getHistory(maxId = 0, reverse = false, isBackLimit = false, additionMsgId = 0, justLoad = false): {cached: boolean, promise: Promise<boolean>} {
const peerId = this.peerId; const peerId = this.peerId;
const isBroadcast = this.appPeersManager.isBroadcast(peerId);
//console.time('appImManager call getHistory'); //console.time('appImManager call getHistory');
const pageCount = Math.min(30, windowSize.height / 38/* * 1.25 */ | 0); const pageCount = Math.min(30, windowSize.height / 75/* * 1.25 */ | 0);
//const loadCount = Object.keys(this.bubbles).length > 0 ? 50 : pageCount; //const loadCount = Object.keys(this.bubbles).length > 0 ? 50 : pageCount;
const realLoadCount = Object.keys(this.bubbles).length > 0/* || additionMsgId */ ? Math.max(40, pageCount) : pageCount;//const realLoadCount = 50; const realLoadCount = isBroadcast ? 20 : (Object.keys(this.bubbles).length > 0 ? Math.max(35, pageCount) : pageCount);
//const realLoadCount = pageCount;//const realLoadCount = 50; //const realLoadCount = pageCount;//const realLoadCount = 50;
let loadCount = realLoadCount; let loadCount = realLoadCount;

2
src/helpers/scrollSaver.ts

@ -74,7 +74,7 @@ export default class ScrollSaver {
//isTouchSupported && isApple && (container.container.style.overflow = ''); //isTouchSupported && isApple && (container.container.style.overflow = '');
scrollable.lastScrollPosition = newScrollTop; scrollable.lastScrollPosition = newScrollTop;
scrollable.lastScrollDirection = 0; // scrollable.lastScrollDirection = 0;
if(IS_SAFARI/* && !isAppleMobile */) { // * fix blinking and jumping if(IS_SAFARI/* && !isAppleMobile */) { // * fix blinking and jumping
reflowScrollableElement(container); reflowScrollableElement(container);

Loading…
Cancel
Save