Merge pull request #1661 from ONLYOFFICE/feature/fix-load-docinfo

Fix loading doc-info for large pdf (show download progress)
This commit is contained in:
maxkadushkin 2022-03-31 10:48:49 +03:00 committed by GitHub
commit e19540a132
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View file

@ -658,7 +658,9 @@ class MainController extends Component {
const storeDocumentInfo = this.props.storeDocumentInfo; const storeDocumentInfo = this.props.storeDocumentInfo;
this.api.asc_registerCallback("asc_onGetDocInfoStart", () => { this.api.asc_registerCallback("asc_onGetDocInfoStart", () => {
storeDocumentInfo.switchIsLoaded(false); this.timerLoading = setTimeout(() => {
storeDocumentInfo.switchIsLoaded(false);
}, 2000);
}); });
this.api.asc_registerCallback("asc_onGetDocInfoStop", () => { this.api.asc_registerCallback("asc_onGetDocInfoStop", () => {
@ -666,10 +668,20 @@ class MainController extends Component {
}); });
this.api.asc_registerCallback("asc_onDocInfo", (obj) => { this.api.asc_registerCallback("asc_onDocInfo", (obj) => {
storeDocumentInfo.changeCount(obj); clearTimeout(this.timerLoading);
this.objectInfo = obj;
if(!this.timerDocInfo) {
this.timerDocInfo = setInterval(() => {
storeDocumentInfo.changeCount(this.objectInfo);
}, 300);
storeDocumentInfo.changeCount(this.objectInfo);
}
}); });
this.api.asc_registerCallback('asc_onGetDocInfoEnd', () => { this.api.asc_registerCallback('asc_onGetDocInfoEnd', () => {
clearTimeout(this.timerLoading);
clearInterval(this.timerDocInfo);
storeDocumentInfo.switchIsLoaded(true); storeDocumentInfo.switchIsLoaded(true);
}); });

View file

@ -20,7 +20,7 @@ export class storeDocumentInfo {
symbolsWSCount: 0, symbolsWSCount: 0,
}; };
isLoaded = false; isLoaded = true;
dataDoc; dataDoc;
switchIsLoaded(value) { switchIsLoaded(value) {