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>} {
|
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;
|
||||||
|
|
||||||
@ -2390,14 +2397,14 @@ export class AppImManager {
|
|||||||
cached = false;
|
cached = false;
|
||||||
promise = result.then((result) => {
|
promise = result.then((result) => {
|
||||||
this.log('getHistory not cached result by maxID:', maxID, reverse, isBackLimit, result, peerID, justLoad);
|
this.log('getHistory not cached result by maxID:', maxID, reverse, isBackLimit, result, peerID, justLoad);
|
||||||
|
|
||||||
if(justLoad) {
|
if(justLoad) {
|
||||||
this.scrollable.onScroll(); // нужно делать из-за ранней прогрузки
|
this.scrollable.onScroll(); // нужно делать из-за ранней прогрузки
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//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);
|
||||||
|
@ -1871,7 +1871,8 @@ export class AppMessagesManager {
|
|||||||
limit: limit,
|
limit: limit,
|
||||||
hash: 0
|
hash: 0
|
||||||
}, {
|
}, {
|
||||||
timeout: APITIMEOUT
|
//timeout: APITIMEOUT,
|
||||||
|
noErrorBox: true
|
||||||
}).then((dialogsResult) => {
|
}).then((dialogsResult) => {
|
||||||
///////this.log('messages.getDialogs result:', dialogsResult);
|
///////this.log('messages.getDialogs result:', dialogsResult);
|
||||||
|
|
||||||
@ -2968,7 +2969,7 @@ export class AppMessagesManager {
|
|||||||
min_id: 0,
|
min_id: 0,
|
||||||
hash: 0
|
hash: 0
|
||||||
}, {
|
}, {
|
||||||
timeout: APITIMEOUT,
|
//timeout: APITIMEOUT,
|
||||||
noErrorBox: true
|
noErrorBox: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -2991,7 +2992,7 @@ export class AppMessagesManager {
|
|||||||
offset_id: appMessagesIDsManager.getMessageLocalID(offsetID),
|
offset_id: appMessagesIDsManager.getMessageLocalID(offsetID),
|
||||||
limit: limit || 20
|
limit: limit || 20
|
||||||
}, {
|
}, {
|
||||||
timeout: APITIMEOUT,
|
//timeout: APITIMEOUT,
|
||||||
noErrorBox: true
|
noErrorBox: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4195,7 +4196,7 @@ export class AppMessagesManager {
|
|||||||
min_id: 0,
|
min_id: 0,
|
||||||
hash: 0
|
hash: 0
|
||||||
}, {
|
}, {
|
||||||
timeout: APITIMEOUT,
|
//timeout: APITIMEOUT,
|
||||||
noErrorBox: true
|
noErrorBox: true
|
||||||
}).then((historyResult: any) => {
|
}).then((historyResult: any) => {
|
||||||
this.log('requestHistory result:', historyResult, maxID, limit, offset);
|
this.log('requestHistory result:', historyResult, maxID, limit, offset);
|
||||||
|
@ -16,6 +16,7 @@ import { InvokeApiOptions } from '../../types';
|
|||||||
/// #endif
|
/// #endif
|
||||||
|
|
||||||
//console.error('apiManager included!');
|
//console.error('apiManager included!');
|
||||||
|
// TODO: если запрос словил флуд, нужно сохранять его параметры и возвращать тот же промис на новый такой же запрос, например - загрузка истории
|
||||||
|
|
||||||
export class ApiManager {
|
export class ApiManager {
|
||||||
public cachedNetworkers: {[x: number]: MTPNetworker} = {};
|
public cachedNetworkers: {[x: number]: MTPNetworker} = {};
|
||||||
@ -290,7 +291,7 @@ export class ApiManager {
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
performRequest(cachedNetworker);
|
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')) {
|
} else if(!options.rawError && (error.code == 500 || error.type == 'MSG_WAIT_FAILED')) {
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
if(options.stopTime) {
|
if(options.stopTime) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user