Browse Source

Fix FILE_REFERENCE_EXPIRED

Fix api timeout error
master
Eduard Kuzmenko 3 years ago
parent
commit
93be4cf3ac
  1. 44
      src/lib/appManagers/appDocsManager.ts
  2. 4
      src/lib/mtproto/apiManager.ts
  3. 8
      src/lib/mtproto/referenceDatabase.ts

44
src/lib/appManagers/appDocsManager.ts

@ -60,27 +60,29 @@ export class AppDocsManager { @@ -60,27 +60,29 @@ export class AppDocsManager {
}
//console.log('saveDoc', apiDoc, this.docs[apiDoc.id]);
if(oldDoc) {
//if(doc._ !== 'documentEmpty' && doc._ === d._) {
if(doc.thumbs) {
if(!oldDoc.thumbs) oldDoc.thumbs = doc.thumbs;
/* else if(apiDoc.thumbs[0].bytes && !d.thumbs[0].bytes) {
d.thumbs.unshift(apiDoc.thumbs[0]);
} else if(d.thumbs[0].url) { // fix for converted thumb in safari
apiDoc.thumbs[0] = d.thumbs[0];
} */
}
//}
return oldDoc;
//return Object.assign(d, apiDoc, context);
//return context ? Object.assign(d, context) : d;
// if(oldDoc) {
// //if(doc._ !== 'documentEmpty' && doc._ === d._) {
// if(doc.thumbs) {
// if(!oldDoc.thumbs) oldDoc.thumbs = doc.thumbs;
// /* else if(apiDoc.thumbs[0].bytes && !d.thumbs[0].bytes) {
// d.thumbs.unshift(apiDoc.thumbs[0]);
// } else if(d.thumbs[0].url) { // fix for converted thumb in safari
// apiDoc.thumbs[0] = d.thumbs[0];
// } */
// }
// //}
// return oldDoc;
// //return Object.assign(d, apiDoc, context);
// //return context ? Object.assign(d, context) : d;
// }
if(!oldDoc) {
this.docs[doc.id] = doc;
}
this.docs[doc.id] = doc;
// * exclude from state
// defineNotNumerableProperties(doc, [/* 'thumbs', */'type', 'h', 'w', 'file_name',
// 'file', 'duration', 'downloaded', 'url', 'audioTitle',
@ -212,6 +214,10 @@ export class AppDocsManager { @@ -212,6 +214,10 @@ export class AppDocsManager {
doc.url = this.getFileURL(doc);
} */
if(oldDoc) {
return Object.assign(oldDoc, doc);
}
return doc;
}

4
src/lib/mtproto/apiManager.ts

@ -479,6 +479,10 @@ export class ApiManager { @@ -479,6 +479,10 @@ export class ApiManager {
setTimeout(() => {
performRequest(cachedNetworker);
}, options.waitTime * 1000);
} else if(error.type === 'UNKNOWN') {
setTimeout(() => {
performRequest(cachedNetworker);
}, 1000);
} else {
rejectPromise(error);
}

8
src/lib/mtproto/referenceDatabase.ts

@ -4,11 +4,9 @@ @@ -4,11 +4,9 @@
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
import type { RequestFilePartTask, RequestFilePartTaskResponse } from "../serviceWorker/index.service";
import { RefreshReferenceTask, RefreshReferenceTaskResponse } from "./apiFileManager";
import type { ApiError } from "./apiManager";
import appMessagesManager from "../appManagers/appMessagesManager";
import { InputFileLocation, Photo } from "../../layer";
import { Photo } from "../../layer";
import { bytesToHex } from "../../helpers/bytes";
import { deepEqual } from "../../helpers/object";
import { MOUNT_CLASS_TO } from "../../config/debug";
@ -61,9 +59,9 @@ class ReferenceDatabase { @@ -61,9 +59,9 @@ class ReferenceDatabase {
if(!contexts) {
contexts = new Set();
this.contexts.set(reference, contexts);
this.links[bytesToHex(reference)] = reference;
}
this.links[bytesToHex(reference)] = reference;
for(const _context of contexts) {
if(deepEqual(_context, context)) {
return;

Loading…
Cancel
Save