|
|
@ -2355,7 +2355,14 @@ export class AppImManager { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// reverse means scroll up
|
|
|
|
/** |
|
|
|
|
|
|
|
* Load and render history |
|
|
|
|
|
|
|
* @param maxID max message id |
|
|
|
|
|
|
|
* @param reverse 'true' means up |
|
|
|
|
|
|
|
* @param isBackLimit is search |
|
|
|
|
|
|
|
* @param additionMsgID for the last message |
|
|
|
|
|
|
|
* @param justLoad do not render |
|
|
|
|
|
|
|
*/ |
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
@ -2397,7 +2404,7 @@ export class AppImManager { |
|
|
|
} |
|
|
|
} |
|
|
|
//console.timeEnd('appImManager call getHistory');
|
|
|
|
//console.timeEnd('appImManager call getHistory');
|
|
|
|
|
|
|
|
|
|
|
|
if(this.peerID != peerID) { |
|
|
|
if(this.peerID != peerID || (this.getHistoryTopPromise != promise && this.getHistoryBottomPromise != promise)) { |
|
|
|
this.log.warn('peer changed'); |
|
|
|
this.log.warn('peer changed'); |
|
|
|
////console.timeEnd('render history total');
|
|
|
|
////console.timeEnd('render history total');
|
|
|
|
return Promise.reject(); |
|
|
|
return Promise.reject(); |
|
|
@ -2453,12 +2460,17 @@ export class AppImManager { |
|
|
|
//ids = ids.slice(removeCount * 2);
|
|
|
|
//ids = ids.slice(removeCount * 2);
|
|
|
|
ids = ids.slice(safeCount); |
|
|
|
ids = ids.slice(safeCount); |
|
|
|
this.scrolledAllDown = false; |
|
|
|
this.scrolledAllDown = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.log('getHistory: slice bottom messages:', ids.length, loadCount); |
|
|
|
|
|
|
|
this.getHistoryBottomPromise = undefined; // !WARNING, это нужно для обратной загрузки истории, если запрос словил флуд
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
//ids = ids.slice(0, removeCount);
|
|
|
|
//ids = ids.slice(0, removeCount);
|
|
|
|
//ids = ids.slice(0, ids.length - (removeCount * 2));
|
|
|
|
//ids = ids.slice(0, ids.length - (removeCount * 2));
|
|
|
|
ids = ids.slice(0, ids.length - safeCount); |
|
|
|
ids = ids.slice(0, ids.length - safeCount); |
|
|
|
this.scrolledAll = false; |
|
|
|
this.scrolledAll = false; |
|
|
|
this.log('getHistory: slice bottom: to:', ids.length, loadCount); |
|
|
|
|
|
|
|
|
|
|
|
this.log('getHistory: slice up messages:', ids.length, loadCount); |
|
|
|
|
|
|
|
this.getHistoryTopPromise = undefined; // !WARNING, это нужно для обратной загрузки истории, если запрос словил флуд
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.log('getHistory: will slice ids:', ids, reverse); |
|
|
|
this.log('getHistory: will slice ids:', ids, reverse); |
|
|
|