Fix flood wait list loading stuck
This commit is contained in:
parent
8992a6e7af
commit
043bdeedb0
@ -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>} {
|
||||
const peerID = this.peerID;
|
||||
|
||||
@ -2397,7 +2404,7 @@ export class AppImManager {
|
||||
}
|
||||
//console.timeEnd('appImManager call getHistory');
|
||||
|
||||
if(this.peerID != peerID) {
|
||||
if(this.peerID != peerID || (this.getHistoryTopPromise != promise && this.getHistoryBottomPromise != promise)) {
|
||||
this.log.warn('peer changed');
|
||||
////console.timeEnd('render history total');
|
||||
return Promise.reject();
|
||||
@ -2453,12 +2460,17 @@ export class AppImManager {
|
||||
//ids = ids.slice(removeCount * 2);
|
||||
ids = ids.slice(safeCount);
|
||||
this.scrolledAllDown = false;
|
||||
|
||||
this.log('getHistory: slice bottom messages:', ids.length, loadCount);
|
||||
this.getHistoryBottomPromise = undefined; // !WARNING, это нужно для обратной загрузки истории, если запрос словил флуд
|
||||
} else {
|
||||
//ids = ids.slice(0, removeCount);
|
||||
//ids = ids.slice(0, ids.length - (removeCount * 2));
|
||||
ids = ids.slice(0, ids.length - safeCount);
|
||||
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);
|
||||
|
@ -1871,7 +1871,8 @@ export class AppMessagesManager {
|
||||
limit: limit,
|
||||
hash: 0
|
||||
}, {
|
||||
timeout: APITIMEOUT
|
||||
//timeout: APITIMEOUT,
|
||||
noErrorBox: true
|
||||
}).then((dialogsResult) => {
|
||||
///////this.log('messages.getDialogs result:', dialogsResult);
|
||||
|
||||
@ -2968,7 +2969,7 @@ export class AppMessagesManager {
|
||||
min_id: 0,
|
||||
hash: 0
|
||||
}, {
|
||||
timeout: APITIMEOUT,
|
||||
//timeout: APITIMEOUT,
|
||||
noErrorBox: true
|
||||
});
|
||||
} else {
|
||||
@ -2991,7 +2992,7 @@ export class AppMessagesManager {
|
||||
offset_id: appMessagesIDsManager.getMessageLocalID(offsetID),
|
||||
limit: limit || 20
|
||||
}, {
|
||||
timeout: APITIMEOUT,
|
||||
//timeout: APITIMEOUT,
|
||||
noErrorBox: true
|
||||
});
|
||||
}
|
||||
@ -4195,7 +4196,7 @@ export class AppMessagesManager {
|
||||
min_id: 0,
|
||||
hash: 0
|
||||
}, {
|
||||
timeout: APITIMEOUT,
|
||||
//timeout: APITIMEOUT,
|
||||
noErrorBox: true
|
||||
}).then((historyResult: any) => {
|
||||
this.log('requestHistory result:', historyResult, maxID, limit, offset);
|
||||
|
@ -16,6 +16,7 @@ import { InvokeApiOptions } from '../../types';
|
||||
/// #endif
|
||||
|
||||
//console.error('apiManager included!');
|
||||
// TODO: если запрос словил флуд, нужно сохранять его параметры и возвращать тот же промис на новый такой же запрос, например - загрузка истории
|
||||
|
||||
export class ApiManager {
|
||||
public cachedNetworkers: {[x: number]: MTPNetworker} = {};
|
||||
@ -290,7 +291,7 @@ export class ApiManager {
|
||||
|
||||
setTimeout(() => {
|
||||
performRequest(cachedNetworker);
|
||||
}, (waitTime + 5) * 1000); // 03.02.2020
|
||||
}, waitTime/* (waitTime + 5) */ * 1000); // 03.02.2020
|
||||
} else if(!options.rawError && (error.code == 500 || error.type == 'MSG_WAIT_FAILED')) {
|
||||
var now = Date.now();
|
||||
if(options.stopTime) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user