MOBILE-4616 chore: Remove some usages of old Service.instance
parent
48259062fd
commit
4b950ac891
|
@ -645,9 +645,8 @@ export class CoreCourseHelperProvider {
|
||||||
|
|
||||||
// Now determine the status of the whole list.
|
// Now determine the status of the whole list.
|
||||||
let status = statuses[0];
|
let status = statuses[0];
|
||||||
const filepool = CoreFilepool.instance;
|
|
||||||
for (let i = 1; i < statuses.length; i++) {
|
for (let i = 1; i < statuses.length; i++) {
|
||||||
status = filepool.determinePackagesStatus(status, statuses[i]);
|
status = CoreFilepool.determinePackagesStatus(status, statuses[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|
|
@ -86,9 +86,6 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
|
||||||
protected onlineObserver?: Subscription;
|
protected onlineObserver?: Subscription;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
const sitesProvider = CoreSites.instance;
|
|
||||||
const device = Device.instance;
|
|
||||||
const translate = Translate.instance;
|
|
||||||
const navigator = window.navigator;
|
const navigator = window.navigator;
|
||||||
|
|
||||||
this.deviceInfo = {
|
this.deviceInfo = {
|
||||||
|
@ -128,7 +125,7 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
|
||||||
this.deviceOsTranslated = matches[1];
|
this.deviceOsTranslated = matches[1];
|
||||||
} else {
|
} else {
|
||||||
this.deviceInfo.deviceOs = 'unknown';
|
this.deviceInfo.deviceOs = 'unknown';
|
||||||
this.deviceOsTranslated = translate.instant('core.unknown');
|
this.deviceOsTranslated = Translate.instant('core.unknown');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -139,11 +136,10 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
|
||||||
this.deviceOsTranslated = matches[1];
|
this.deviceOsTranslated = matches[1];
|
||||||
} else {
|
} else {
|
||||||
this.deviceInfo.deviceOs = 'unknown';
|
this.deviceInfo.deviceOs = 'unknown';
|
||||||
this.deviceOsTranslated = translate.instant('core.unknown');
|
this.deviceOsTranslated = Translate.instant('core.unknown');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (navigator) {
|
|
||||||
if (navigator.userAgent) {
|
if (navigator.userAgent) {
|
||||||
this.deviceInfo.userAgent = navigator.userAgent;
|
this.deviceInfo.userAgent = navigator.userAgent;
|
||||||
}
|
}
|
||||||
|
@ -151,27 +147,24 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
|
||||||
if (navigator.language) {
|
if (navigator.language) {
|
||||||
this.deviceInfo.browserLanguage = navigator.language;
|
this.deviceInfo.browserLanguage = navigator.language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Device.cordova) {
|
||||||
|
this.deviceInfo.cordovaVersion = Device.cordova;
|
||||||
|
}
|
||||||
|
if (Device.platform) {
|
||||||
|
this.deviceInfo.platform = Device.platform;
|
||||||
|
}
|
||||||
|
if (Device.version) {
|
||||||
|
this.deviceInfo.osVersion = Device.version;
|
||||||
|
}
|
||||||
|
if (Device.model) {
|
||||||
|
this.deviceInfo.model = Device.model;
|
||||||
|
}
|
||||||
|
if (Device.uuid) {
|
||||||
|
this.deviceInfo.uuid = Device.uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device) {
|
const currentSite = CoreSites.getCurrentSite();
|
||||||
if (device.cordova) {
|
|
||||||
this.deviceInfo.cordovaVersion = device.cordova;
|
|
||||||
}
|
|
||||||
if (device.platform) {
|
|
||||||
this.deviceInfo.platform = device.platform;
|
|
||||||
}
|
|
||||||
if (device.version) {
|
|
||||||
this.deviceInfo.osVersion = device.version;
|
|
||||||
}
|
|
||||||
if (device.model) {
|
|
||||||
this.deviceInfo.model = device.model;
|
|
||||||
}
|
|
||||||
if (device.uuid) {
|
|
||||||
this.deviceInfo.uuid = device.uuid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentSite = sitesProvider.getCurrentSite();
|
|
||||||
this.deviceInfo.siteId = currentSite?.getId();
|
this.deviceInfo.siteId = currentSite?.getId();
|
||||||
this.deviceInfo.siteVersion = currentSite?.getInfo()?.release;
|
this.deviceInfo.siteVersion = currentSite?.getInfo()?.release;
|
||||||
|
|
||||||
|
@ -190,14 +183,11 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
|
||||||
* Async part of the constructor.
|
* Async part of the constructor.
|
||||||
*/
|
*/
|
||||||
protected async asyncInit(): Promise<void> {
|
protected async asyncInit(): Promise<void> {
|
||||||
const sitesProvider = CoreSites.instance;
|
|
||||||
const fileProvider = CoreFile.instance;
|
|
||||||
|
|
||||||
const lang = await CoreLang.getCurrentLanguage();
|
const lang = await CoreLang.getCurrentLanguage();
|
||||||
this.deviceInfo.currentLanguage = lang;
|
this.deviceInfo.currentLanguage = lang;
|
||||||
this.currentLangName = CoreConstants.CONFIG.languages[lang];
|
this.currentLangName = CoreConstants.CONFIG.languages[lang];
|
||||||
|
|
||||||
const currentSite = sitesProvider.getCurrentSite();
|
const currentSite = CoreSites.getCurrentSite();
|
||||||
const isSingleFixedSite = await CoreLoginHelper.isSingleFixedSite();
|
const isSingleFixedSite = await CoreLoginHelper.isSingleFixedSite();
|
||||||
const sites = await CoreLoginHelper.getAvailableSites();
|
const sites = await CoreLoginHelper.getAvailableSites();
|
||||||
const firstUrl = isSingleFixedSite && sites[0].url;
|
const firstUrl = isSingleFixedSite && sites[0].url;
|
||||||
|
@ -207,10 +197,10 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
|
||||||
this.displaySiteUrl = !!this.deviceInfo.siteUrl &&
|
this.displaySiteUrl = !!this.deviceInfo.siteUrl &&
|
||||||
(currentSite ?? CoreSitesFactory.makeUnauthenticatedSite(this.deviceInfo.siteUrl)).shouldDisplayInformativeLinks();
|
(currentSite ?? CoreSitesFactory.makeUnauthenticatedSite(this.deviceInfo.siteUrl)).shouldDisplayInformativeLinks();
|
||||||
|
|
||||||
if (fileProvider.isAvailable()) {
|
if (CoreFile.isAvailable()) {
|
||||||
const basepath = await fileProvider.getBasePath();
|
const basepath = await CoreFile.getBasePath();
|
||||||
this.deviceInfo.fileSystemRoot = basepath;
|
this.deviceInfo.fileSystemRoot = basepath;
|
||||||
this.fsClickable = fileProvider.usesHTMLAPI();
|
this.fsClickable = CoreFile.usesHTMLAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
const showDevOptionsOnConfig = await CoreConfig.get('showDevOptions', 0);
|
const showDevOptionsOnConfig = await CoreConfig.get('showDevOptions', 0);
|
||||||
|
|
|
@ -136,11 +136,10 @@ export class CoreSettingsHelperProvider {
|
||||||
// Clear cache tables.
|
// Clear cache tables.
|
||||||
const cleanSchemas = CoreSites.getSiteTableSchemasToClear(site);
|
const cleanSchemas = CoreSites.getSiteTableSchemasToClear(site);
|
||||||
const promises: Promise<number | void>[] = cleanSchemas.map((name) => site.getDb().deleteRecords(name));
|
const promises: Promise<number | void>[] = cleanSchemas.map((name) => site.getDb().deleteRecords(name));
|
||||||
const filepoolService = CoreFilepool.instance;
|
|
||||||
|
|
||||||
promises.push(site.deleteFolder().then(() => {
|
promises.push(site.deleteFolder().then(() => {
|
||||||
filepoolService.clearAllPackagesStatus(siteId);
|
CoreFilepool.clearAllPackagesStatus(siteId);
|
||||||
filepoolService.clearFilepool(siteId);
|
CoreFilepool.clearFilepool(siteId);
|
||||||
CoreCourse.clearAllCoursesStatus(siteId);
|
CoreCourse.clearAllCoursesStatus(siteId);
|
||||||
|
|
||||||
siteInfo.spaceUsage = 0;
|
siteInfo.spaceUsage = 0;
|
||||||
|
@ -149,7 +148,7 @@ export class CoreSettingsHelperProvider {
|
||||||
}).catch(async (error) => {
|
}).catch(async (error) => {
|
||||||
if (error && error.code === FileError.NOT_FOUND_ERR) {
|
if (error && error.code === FileError.NOT_FOUND_ERR) {
|
||||||
// Not found, set size 0.
|
// Not found, set size 0.
|
||||||
filepoolService.clearAllPackagesStatus(siteId);
|
CoreFilepool.clearAllPackagesStatus(siteId);
|
||||||
siteInfo.spaceUsage = 0;
|
siteInfo.spaceUsage = 0;
|
||||||
} else {
|
} else {
|
||||||
// Error, recalculate the site usage.
|
// Error, recalculate the site usage.
|
||||||
|
|
|
@ -82,7 +82,7 @@ export class CoreWindow {
|
||||||
if (!CoreFileHelper.isOpenableInApp({ filename })) {
|
if (!CoreFileHelper.isOpenableInApp({ filename })) {
|
||||||
try {
|
try {
|
||||||
await CoreFileHelper.showConfirmOpenUnsupportedFile(false, { filename });
|
await CoreFileHelper.showConfirmOpenUnsupportedFile(false, { filename });
|
||||||
} catch (error) {
|
} catch {
|
||||||
return; // Cancelled, stop.
|
return; // Cancelled, stop.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue