Render instantly more messages if possible
This commit is contained in:
parent
9c5c9741b2
commit
ef2c38902c
@ -2493,16 +2493,33 @@ export class AppImManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let additionMsgIDs: number[];
|
||||||
|
if(additionMsgID) {
|
||||||
|
const historyStorage = appMessagesManager.historiesStorage[peerID];
|
||||||
|
if(historyStorage && historyStorage.history.length < loadCount) {
|
||||||
|
additionMsgIDs = historyStorage.history.slice();
|
||||||
|
|
||||||
|
// * filter last album, because we don't know is this the last item
|
||||||
|
for(let i = additionMsgIDs.length - 1; i >= 0; --i) {
|
||||||
|
const message = appMessagesManager.getMessage(additionMsgIDs[i]);
|
||||||
|
if(message.grouped_id) additionMsgIDs.splice(i, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
maxID = additionMsgIDs[additionMsgIDs.length - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* const result = additionMsgID ?
|
/* const result = additionMsgID ?
|
||||||
{history: [additionMsgID]} :
|
{history: [additionMsgID]} :
|
||||||
appMessagesManager.getHistory(this.peerID, maxID, loadCount, backLimit); */
|
appMessagesManager.getHistory(this.peerID, maxID, loadCount, backLimit); */
|
||||||
let result: ReturnType<AppMessagesManager['getHistory']> | {history: number[]} = appMessagesManager.getHistory(this.peerID, maxID, loadCount, backLimit);
|
let result: ReturnType<AppMessagesManager['getHistory']> | {history: number[]} = appMessagesManager.getHistory(this.peerID, maxID, loadCount, backLimit);
|
||||||
let resultPromise: Promise<any>;
|
let resultPromise: Promise<any>;
|
||||||
|
|
||||||
const isFirstMessageRender = !!additionMsgID && result instanceof Promise && !appMessagesManager.getMessage(additionMsgID).grouped_id;
|
//const isFirstMessageRender = !!additionMsgID && result instanceof Promise && !appMessagesManager.getMessage(additionMsgID).grouped_id;
|
||||||
|
const isFirstMessageRender = additionMsgIDs?.length;
|
||||||
if(isFirstMessageRender) {
|
if(isFirstMessageRender) {
|
||||||
resultPromise = result as Promise<any>;
|
resultPromise = result as Promise<any>;
|
||||||
result = {history: [additionMsgID]};
|
result = {history: additionMsgIDs};
|
||||||
//additionMsgID = 0;
|
//additionMsgID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2551,8 +2568,7 @@ export class AppImManager {
|
|||||||
|
|
||||||
if(isFirstMessageRender) {
|
if(isFirstMessageRender) {
|
||||||
waitPromise.then(() => {
|
waitPromise.then(() => {
|
||||||
const mids = getObjectKeysAndSort(this.bubbles, 'desc');
|
const mids = getObjectKeysAndSort(this.bubbles, 'desc').filter(mid => !additionMsgIDs.includes(mid));
|
||||||
mids.findAndSplice(mid => mid == additionMsgID);
|
|
||||||
mids.forEach((mid, idx) => {
|
mids.forEach((mid, idx) => {
|
||||||
const bubble = this.bubbles[mid];
|
const bubble = this.bubbles[mid];
|
||||||
|
|
||||||
@ -2568,6 +2584,10 @@ export class AppImManager {
|
|||||||
}, {once: true});
|
}, {once: true});
|
||||||
//this.log('supa', bubble);
|
//this.log('supa', bubble);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.loadMoreHistory(true, true);
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user