MOBILE-3833 core: Fix initialization
parent
5542b15ed9
commit
8a2309522c
|
@ -24,4 +24,9 @@ export class CoreApplicationInitStatus extends ApplicationInitStatus {
|
||||||
super(injector.get(APP_INITIALIZER, []));
|
super(injector.get(APP_INITIALIZER, []));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
whenDone(callback: () => unknown): void {
|
||||||
|
// eslint-disable-next-line promise/catch-or-return, promise/no-callback-in-promise
|
||||||
|
this.donePromise.then(callback);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,17 +102,15 @@ export class CoreFilepoolProvider {
|
||||||
/**
|
/**
|
||||||
* Initialize queue.
|
* Initialize queue.
|
||||||
*/
|
*/
|
||||||
async initialize(): Promise<void> {
|
initialize(): void {
|
||||||
// Waiting for the app to be ready to start processing the queue.
|
// Start processing the queue once the app is ready.
|
||||||
await ApplicationInit.donePromise;
|
ApplicationInit.whenDone(() => {
|
||||||
|
this.checkQueueProcessing();
|
||||||
|
|
||||||
this.checkQueueProcessing();
|
// Start queue when device goes online.
|
||||||
|
Network.onConnect().subscribe(() => {
|
||||||
// Start queue when device goes online.
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
Network.onConnect().subscribe(() => {
|
NgZone.run(() => this.checkQueueProcessing());
|
||||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
|
||||||
NgZone.run(() => {
|
|
||||||
this.checkQueueProcessing();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ export class CoreLangProvider {
|
||||||
document.documentElement.setAttribute('dir', dir);
|
document.documentElement.setAttribute('dir', dir);
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.initializeCurrentLanguage();
|
this.initializeCurrentLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -57,6 +57,8 @@ import { Zip as ZipService } from '@ionic-native/zip/ngx';
|
||||||
|
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
|
import { CoreApplicationInitStatus } from '@classes/application-init-status';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injector instance used to resolve singletons.
|
* Injector instance used to resolve singletons.
|
||||||
*/
|
*/
|
||||||
|
@ -198,7 +200,7 @@ export const ModalController = makeSingleton(ModalControllerService);
|
||||||
export const PopoverController = makeSingleton(PopoverControllerService);
|
export const PopoverController = makeSingleton(PopoverControllerService);
|
||||||
export const ToastController = makeSingleton(ToastControllerService);
|
export const ToastController = makeSingleton(ToastControllerService);
|
||||||
export const GestureController = makeSingleton(GestureControllerService);
|
export const GestureController = makeSingleton(GestureControllerService);
|
||||||
export const ApplicationInit = makeSingleton(ApplicationInitStatus);
|
export const ApplicationInit = makeSingleton<CoreApplicationInitStatus>(ApplicationInitStatus);
|
||||||
export const Application = makeSingleton(ApplicationRef);
|
export const Application = makeSingleton(ApplicationRef);
|
||||||
export const NavController = makeSingleton(NavControllerService);
|
export const NavController = makeSingleton(NavControllerService);
|
||||||
export const Router = makeSingleton(RouterService);
|
export const Router = makeSingleton(RouterService);
|
||||||
|
|
|
@ -44,7 +44,7 @@ export class CoreSubscriptions {
|
||||||
// Unsubscribe using a timeout because we can receive a value immediately.
|
// Unsubscribe using a timeout because we can receive a value immediately.
|
||||||
setTimeout(() => subscription.unsubscribe(), 0);
|
setTimeout(() => subscription.unsubscribe(), 0);
|
||||||
|
|
||||||
onError?.call(error);
|
onError && onError(error);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue