MOBILE-4470 core: Make DownloadStatus types match const names

main
Dani Palou 2024-04-02 14:36:02 +02:00
parent 99b3f3db52
commit 8b2b130e14
22 changed files with 93 additions and 95 deletions

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
import { Component, Input, ViewChild, ElementRef, OnInit, OnDestroy, Optional } from '@angular/core';
import { CoreTabsComponent } from '@components/tabs/tabs';
@ -575,7 +575,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo
/**
* @inheritdoc
*/
protected showStatus(status: TDownloadStatus): void {
protected showStatus(status: DownloadStatus): void {
this.showSpinner = status === DownloadStatus.DOWNLOADING;
}

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
import { safeNumber, SafeNumber } from '@/core/utils/types';
import { Component, OnDestroy, OnInit, Optional } from '@angular/core';
@ -543,7 +543,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
* @param status The current status.
* @param previousStatus The previous status. If not defined, there is no previous status.
*/
protected showStatus(status: TDownloadStatus, previousStatus?: TDownloadStatus): void {
protected showStatus(status: DownloadStatus, previousStatus?: DownloadStatus): void {
this.showStatusSpinner = status === DownloadStatus.DOWNLOADING;
if (status === DownloadStatus.DOWNLOADED && previousStatus === DownloadStatus.DOWNLOADING) {

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
import { Injectable } from '@angular/core';
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
@ -36,7 +36,7 @@ export class AddonModResourcePrefetchHandlerService extends CoreCourseResourcePr
/**
* @inheritdoc
*/
determineStatus(module: CoreCourseAnyModuleData, status: TDownloadStatus): TDownloadStatus {
determineStatus(module: CoreCourseAnyModuleData, status: DownloadStatus): DownloadStatus {
if (status === DownloadStatus.DOWNLOADED && module) {
// If the main file is an external file, always display the module as outdated.
if ('contentsinfo' in module && module.contentsinfo) {

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
import { Component, Input, OnInit, Optional } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component';
@ -578,7 +578,7 @@ export class AddonModScormIndexComponent extends CoreCourseModuleMainActivityCom
/**
* @inheritdoc
*/
protected async showStatus(status: TDownloadStatus): Promise<void> {
protected async showStatus(status: DownloadStatus): Promise<void> {
if (status === DownloadStatus.OUTDATED && this.scorm) {
// Only show the outdated message if the file should be downloaded.

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { CoreConstants, DownloadStatus, TDownloadStatus } from '@/core/constants';
import { CoreConstants, DownloadStatus } from '@/core/constants';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit } from '@angular/core';
import { CoreCourse, CoreCourseProvider } from '@features/course/services/course';
import {
@ -607,7 +607,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy {
* @param module Module to update.
* @param status Module status.
*/
protected updateModuleStatus(module: AddonStorageManagerModule, status: TDownloadStatus): void {
protected updateModuleStatus(module: AddonStorageManagerModule, status: DownloadStatus): void {
if (!status) {
return;
}
@ -649,7 +649,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy {
*
* @param status Status to show.
*/
protected updateCourseStatus(status: TDownloadStatus): void {
protected updateCourseStatus(status: DownloadStatus): void {
const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status);
this.prefetchCourseData.status = statusData.status;
@ -758,5 +758,5 @@ type AddonStorageManagerModule = CoreCourseModuleData & {
calculatingSize: boolean;
prefetchHandler?: CoreCourseModulePrefetchHandler;
spinner?: boolean;
downloadStatus?: TDownloadStatus;
downloadStatus?: DownloadStatus;
};

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { CoreCourse, CoreCourseProvider } from '@features/course/services/course';
import { CoreCourseHelper } from '@features/course/services/course-helper';
@ -175,7 +175,7 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy
*
* @param courseId Updated course id.
*/
private async onCourseUpdated(courseId: number, status: TDownloadStatus): Promise<void> {
private async onCourseUpdated(courseId: number, status: DownloadStatus): Promise<void> {
if (courseId == CoreCourseProvider.ALL_COURSES_CLEARED) {
this.setDownloadedCourses([]);

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
import { CoreAnimations } from '@components/animations';
/**
@ -31,7 +31,7 @@ import { CoreAnimations } from '@components/animations';
})
export class CoreDownloadRefreshComponent {
@Input() status?: TDownloadStatus; // Download status.
@Input() status?: DownloadStatus; // Download status.
@Input() statusTranslatable?: string; // Download status translatable string.
@Input() enabled = false; // Whether the download is enabled.
@Input() loading = true; // Force loading status when is not downloading.

View File

@ -23,7 +23,7 @@ import { CoreMimetypeUtils } from '@services/utils/mimetype';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils, CoreUtilsOpenFileOptions, OpenFileAction } from '@services/utils/utils';
import { CoreTextUtils } from '@services/utils/text';
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreWSFile } from '@services/ws';
import { CorePlatform } from '@services/platform';
@ -53,7 +53,7 @@ export class CoreFileComponent implements OnInit, OnDestroy {
fileIcon?: string;
fileName!: string;
fileSizeReadable?: string;
state?: TDownloadStatus;
state?: DownloadStatus;
timemodified!: number;
isIOS = false;
openButtonIcon = '';

View File

@ -46,7 +46,7 @@ export const enum ModPurpose {
MOD_PURPOSE_OTHER = 'other',
}
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/no-redeclare */
/**
* Possible statuses for downloaded modules/files.
*/
@ -55,6 +55,7 @@ export const DownloadedStatus = {
DOWNLOADING: 'downloading',
OUTDATED: 'outdated',
} as const;
export type DownloadedStatus = typeof DownloadedStatus[keyof typeof DownloadedStatus];
/**
* Possible statuses for not downloaded modules/files.
@ -63,6 +64,7 @@ export const NotDownloadedStatus = {
DOWNLOADABLE_NOT_DOWNLOADED: 'notdownloaded',
NOT_DOWNLOADABLE: 'notdownloadable',
} as const;
export type NotDownloadedStatus = typeof NotDownloadedStatus[keyof typeof NotDownloadedStatus];
/**
* Possible statuses for modules regarding download.
@ -71,12 +73,8 @@ export const DownloadStatus = {
...DownloadedStatus,
...NotDownloadedStatus,
} as const;
export type TDownloadedStatus = typeof DownloadedStatus[keyof typeof DownloadedStatus];
export type TNotDownloadedStatus = typeof NotDownloadedStatus[keyof typeof NotDownloadedStatus];
export type TDownloadStatus = typeof DownloadStatus[keyof typeof DownloadStatus];
/* eslint-enable @typescript-eslint/naming-convention */
export type DownloadStatus = typeof DownloadStatus[keyof typeof DownloadStatus];
/* eslint-enable @typescript-eslint/naming-convention, @typescript-eslint/no-redeclare */
/**
* Static class to contain all the core constants.

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
import { OnInit, OnDestroy, Input, Output, EventEmitter, Component, Optional, Inject } from '@angular/core';
import { CoreAnyError } from '@classes/errors/error';
import { CoreNetwork } from '@services/network';
@ -65,7 +65,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
protected isCurrentView = false; // Whether the component is in the current view.
protected siteId?: string; // Current Site ID.
protected statusObserver?: CoreEventObserver; // Observer of package status. Only if setStatusListener is called.
currentStatus?: TDownloadStatus; // The current status of the module. Only if setStatusListener is called.
currentStatus?: DownloadStatus; // The current status of the module. Only if setStatusListener is called.
downloadTimeReadable?: string; // Last download time in a readable format. Only if setStatusListener is called.
protected completionObserver?: CoreEventObserver;
@ -282,7 +282,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
* @param previousStatus The previous status. If not defined, there is no previous status.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected showStatus(status: TDownloadStatus, previousStatus?: TDownloadStatus): void {
protected showStatus(status: DownloadStatus, previousStatus?: DownloadStatus): void {
// To be overridden.
}

View File

@ -27,7 +27,7 @@ import {
CoreCourseModulePrefetchDelegate,
CoreCourseModulePrefetchHandler,
} from '@features/course/services/module-prefetch-delegate';
import { CoreConstants, DownloadStatus, TDownloadStatus } from '@/core/constants';
import { CoreConstants, DownloadStatus } from '@/core/constants';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { BehaviorSubject } from 'rxjs';
@ -146,7 +146,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
*
* @param prefetchStatus Module status.
*/
protected updateModuleStatus(prefetchStatus: TDownloadStatus | null): void {
protected updateModuleStatus(prefetchStatus: DownloadStatus | null): void {
if (!prefetchStatus) {
return;
}

View File

@ -28,7 +28,7 @@ import {
CoreCourseModuleCompletionStatus,
CoreCourseGetContentsWSModule,
} from './course';
import { CoreConstants, DownloadStatus, TDownloadStatus, ContextLevel } from '@/core/constants';
import { CoreConstants, DownloadStatus, ContextLevel } from '@/core/constants';
import { CoreLogger } from '@singletons/logger';
import { ApplicationInit, makeSingleton, Translate } from '@singletons';
import { CoreFilepool } from '@services/filepool';
@ -82,7 +82,7 @@ import { LazyRoutesModule } from '@/app/app-routing.module';
export type CoreCourseModulePrefetchInfo = CoreCourseModulePackageLastDownloaded & {
size: number; // Downloaded size.
sizeReadable: string; // Downloadable size in a readable format.
status: TDownloadStatus; // Module status.
status: DownloadStatus; // Module status.
statusIcon?: string; // Icon's name of the module status.
};
@ -120,7 +120,7 @@ export type CoreCourseCoursesProgress = {
};
export type CorePrefetchStatusInfo = {
status: TDownloadStatus; // Status of the prefetch.
status: DownloadStatus; // Status of the prefetch.
statusTranslatable: string; // Status translatable string.
icon: string; // Icon based on the status.
loading: boolean; // If it's a loading status.
@ -328,7 +328,7 @@ export class CoreCourseHelperProvider {
checkUpdates: boolean = true,
): Promise<CoreCourseSectionWithStatus[]> {
let allSectionsSection: CoreCourseSectionWithStatus | undefined;
let allSectionsStatus = DownloadStatus.NOT_DOWNLOADABLE as TDownloadStatus;
let allSectionsStatus = DownloadStatus.NOT_DOWNLOADABLE as DownloadStatus;
const promises = sections.map(async (section: CoreCourseSectionWithStatus) => {
section.isCalculating = true;
@ -632,9 +632,9 @@ export class CoreCourseHelperProvider {
* @param courses Courses
* @returns Promise resolved with the status.
*/
async determineCoursesStatus(courses: CoreCourseBasicData[]): Promise<TDownloadStatus> {
async determineCoursesStatus(courses: CoreCourseBasicData[]): Promise<DownloadStatus> {
// Get the status of each course.
const promises: Promise<TDownloadStatus>[] = [];
const promises: Promise<DownloadStatus>[] = [];
const siteId = CoreSites.getCurrentSiteId();
courses.forEach((course) => {
@ -817,7 +817,7 @@ export class CoreCourseHelperProvider {
files?: CoreCourseModuleContentFile[],
siteId?: string,
options: CoreUtilsOpenFileOptions = {},
): Promise<{ fixedUrl: string; path: string; status?: TDownloadStatus }> {
): Promise<{ fixedUrl: string; path: string; status?: DownloadStatus }> {
siteId = siteId || CoreSites.getCurrentSiteId();
@ -910,7 +910,7 @@ export class CoreCourseHelperProvider {
courseId: number,
fixedUrl: string,
files: CoreCourseModuleContentFile[],
status: TDownloadStatus,
status: DownloadStatus,
component?: string,
componentId?: string | number,
siteId?: string,
@ -1239,7 +1239,7 @@ export class CoreCourseHelperProvider {
* @param status Course status.
* @returns Prefetch status info.
*/
getCoursePrefetchStatusInfo(status: TDownloadStatus): CorePrefetchStatusInfo {
getCoursePrefetchStatusInfo(status: DownloadStatus): CorePrefetchStatusInfo {
const prefetchStatus: CorePrefetchStatusInfo = {
status: status,
icon: this.getPrefetchStatusIcon(status, false),
@ -1266,7 +1266,7 @@ export class CoreCourseHelperProvider {
* @param status Courses status.
* @returns Prefetch status info.
*/
getCoursesPrefetchStatusInfo(status: TDownloadStatus): CorePrefetchStatusInfo {
getCoursesPrefetchStatusInfo(status: DownloadStatus): CorePrefetchStatusInfo {
const prefetchStatus: CorePrefetchStatusInfo = {
status: status,
icon: this.getPrefetchStatusIcon(status, false),
@ -1294,7 +1294,7 @@ export class CoreCourseHelperProvider {
* @param trustDownload True to show download success, false to show an outdated status when downloaded.
* @returns Icon name.
*/
getPrefetchStatusIcon(status: TDownloadStatus, trustDownload: boolean = false): string {
getPrefetchStatusIcon(status: DownloadStatus, trustDownload: boolean = false): string {
if (status === DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED) {
return CoreConstants.ICON_NOT_DOWNLOADED;
}
@ -1714,7 +1714,7 @@ export class CoreCourseHelperProvider {
}
// Download all the sections except "All sections".
let allSectionsStatus = DownloadStatus.NOT_DOWNLOADABLE as TDownloadStatus;
let allSectionsStatus = DownloadStatus.NOT_DOWNLOADABLE as DownloadStatus;
section.isDownloading = true;
const promises = sections.map(async (section) => {
@ -2073,7 +2073,7 @@ export type CoreCourseSection = CoreCourseWSSection & {
* Section with data about prefetch.
*/
export type CoreCourseSectionWithStatus = CoreCourseSection & {
downloadStatus?: TDownloadStatus; // Section status.
downloadStatus?: DownloadStatus; // Section status.
isDownloading?: boolean; // Whether section is being downloaded.
total?: number; // Total of modules being downloaded.
count?: number; // Number of downloaded modules.

View File

@ -22,7 +22,7 @@ import { CoreSitesCommonWSOptions, CoreSites, CoreSitesReadingStrategy } from '@
import { CoreTimeUtils } from '@services/utils/time';
import { CoreUtils } from '@services/utils/utils';
import { CoreSite } from '@classes/sites/site';
import { CoreConstants, DownloadStatus, TDownloadStatus } from '@/core/constants';
import { CoreConstants, DownloadStatus } from '@/core/constants';
import { makeSingleton, Translate } from '@singletons';
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
@ -477,7 +477,7 @@ export class CoreCourseProvider {
* @param siteId Site ID. If not defined, current site.
* @returns Promise resolved with the status.
*/
async getCourseStatus(courseId: number, siteId?: string): Promise<TDownloadStatus> {
async getCourseStatus(courseId: number, siteId?: string): Promise<DownloadStatus> {
try {
const entry = await this.getCourseStatusData(courseId, siteId);
@ -494,7 +494,7 @@ export class CoreCourseProvider {
* @returns Resolves with an array containing downloaded course ids.
*/
async getDownloadedCourseIds(siteId?: string): Promise<number[]> {
const downloadedStatuses: TDownloadStatus[] =
const downloadedStatuses: DownloadStatus[] =
[DownloadStatus.DOWNLOADED, DownloadStatus.DOWNLOADING, DownloadStatus.OUTDATED];
const site = await CoreSites.getSite(siteId);
const entries = await this.statusTables[site.getId()].getManyWhere({
@ -1403,7 +1403,7 @@ export class CoreCourseProvider {
* @param siteId Site ID. If not defined, current site.
* @returns Promise resolved when the status is changed. Resolve param: new status.
*/
async setCoursePreviousStatus(courseId: number, siteId?: string): Promise<TDownloadStatus> {
async setCoursePreviousStatus(courseId: number, siteId?: string): Promise<DownloadStatus> {
siteId = siteId || CoreSites.getCurrentSiteId();
this.logger.debug(`Set previous status for course ${courseId} in site ${siteId}`);
@ -1436,7 +1436,7 @@ export class CoreCourseProvider {
* @param siteId Site ID. If not defined, current site.
* @returns Promise resolved when the status is stored.
*/
async setCourseStatus(courseId: number, status: TDownloadStatus, siteId?: string): Promise<void> {
async setCourseStatus(courseId: number, status: DownloadStatus, siteId?: string): Promise<void> {
siteId = siteId || CoreSites.getCurrentSiteId();
this.logger.debug(`Set status '${status}' for course ${courseId} in site ${siteId}`);
@ -1444,7 +1444,7 @@ export class CoreCourseProvider {
const site = await CoreSites.getSite(siteId);
let downloadTime = 0;
let previousDownloadTime = 0;
let previousStatus: TDownloadStatus | undefined;
let previousStatus: DownloadStatus | undefined;
if (status === DownloadStatus.DOWNLOADING) {
// Set download time if course is now downloading.
@ -1534,7 +1534,7 @@ export class CoreCourseProvider {
* @param status New course status.
* @param siteId Site ID. If not defined, current site.
*/
protected triggerCourseStatusChanged(courseId: number, status: TDownloadStatus, siteId?: string): void {
protected triggerCourseStatusChanged(courseId: number, status: DownloadStatus, siteId?: string): void {
CoreEvents.trigger(CoreEvents.COURSE_STATUS_CHANGED, {
courseId: courseId,
status: status,

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
import { CoreSiteSchema } from '@services/sites';
/**
@ -121,8 +121,8 @@ export const OFFLINE_SITE_SCHEMA: CoreSiteSchema = {
export type CoreCourseStatusDBRecord = {
id: number;
status: TDownloadStatus;
previous: TDownloadStatus | undefined;
status: DownloadStatus;
previous: DownloadStatus | undefined;
updated: number;
downloadTime: number;
previousDownloadTime: number;

View File

@ -25,7 +25,7 @@ import { makeSingleton } from '@singletons';
import { CoreCourseModuleData } from './course-helper';
import { CoreNavigationOptions } from '@services/navigator';
import { CoreIonicColorNames } from '@singletons/colors';
import { TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
/**
* Interface that all course module handlers must implement.
@ -223,7 +223,7 @@ export interface CoreCourseModuleHandlerData {
*
* @param status Module status.
*/
updateStatus?(status: TDownloadStatus): void;
updateStatus?(status: DownloadStatus): void;
/**
* On Destroy function in case it's needed.

View File

@ -25,7 +25,7 @@ import { CoreUtils } from '@services/utils/utils';
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseModuleContentFile } from './course';
import { CoreCache } from '@classes/cache';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { DownloadStatus, TDownloadStatus, TDownloadedStatus, ContextLevel } from '@/core/constants';
import { DownloadStatus, DownloadedStatus, ContextLevel } from '@/core/constants';
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
import { makeSingleton } from '@singletons';
import { CoreEvents, CoreEventSectionStatusChangedData } from '@singletons/events';
@ -160,7 +160,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
* @param status Current status.
* @returns Module status.
*/
determineModuleStatus(module: CoreCourseAnyModuleData, status: TDownloadStatus): TDownloadStatus {
determineModuleStatus(module: CoreCourseAnyModuleData, status: DownloadStatus): DownloadStatus {
const handler = this.getPrefetchHandlerFor(module.modname);
const siteId = CoreSites.getCurrentSiteId();
@ -528,7 +528,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
updates?: CourseUpdates | false,
refresh?: boolean,
sectionId?: number,
): Promise<TDownloadStatus> {
): Promise<DownloadStatus> {
const handler = this.getPrefetchHandlerFor(module.modname);
if (!handler) {
@ -538,7 +538,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
// Check if the status is cached.
const packageId = CoreFilepool.getPackageId(handler.component, module.id);
const status = this.statusCache.getValue<TDownloadStatus>(packageId, 'status');
const status = this.statusCache.getValue<DownloadStatus>(packageId, 'status');
if (!refresh && status !== undefined) {
this.storeCourseAndSection(packageId, courseId, sectionId);
@ -573,7 +573,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
updates?: CourseUpdates | false,
refresh?: boolean,
sectionId?: number,
): Promise<TDownloadedStatus | null> {
): Promise<DownloadedStatus | null> {
const handler = this.getPrefetchHandlerFor(module.modname);
if (!handler) {
// No handler found, module not downloadable.
@ -582,7 +582,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
// Check if the status is cached.
const packageId = CoreFilepool.getPackageId(handler.component, module.id);
const status = this.statusCache.getValue<TDownloadStatus>(packageId, 'status');
const status = this.statusCache.getValue<DownloadStatus>(packageId, 'status');
if (!refresh && status !== undefined) {
this.storeCourseAndSection(packageId, courseId, sectionId);
@ -617,7 +617,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
courseId: number,
updates?: CourseUpdates | false,
sectionId?: number,
): Promise<{status: TDownloadStatus; updateStatus: boolean}> {
): Promise<{status: DownloadStatus; updateStatus: boolean}> {
// Check if the module is downloadable.
const downloadable = await this.isModuleDownloadable(module, courseId);
if (!downloadable) {
@ -654,7 +654,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
courseId: number,
updates?: CourseUpdates | false,
sectionId?: number,
): Promise<{status: TDownloadedStatus | null; updateStatus: boolean}> {
): Promise<{status: DownloadedStatus | null; updateStatus: boolean}> {
// Get the saved package status.
const siteId = CoreSites.getCurrentSiteId();
const currentStatus = await CoreFilepool.getPackageStatus(siteId, handler.component, module.id);
@ -718,7 +718,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
} catch {
// Error checking if module has updates.
const packageId = CoreFilepool.getPackageId(handler.component, module.id);
const status = this.statusCache.getValue<TDownloadStatus>(packageId, 'status', true);
const status = this.statusCache.getValue<DownloadStatus>(packageId, 'status', true);
return {
status: status ? this.filterDownloadedStatus(status) : null,
@ -733,7 +733,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
* @param status Status.
* @returns Filtered status, null for not downloaded statuses.
*/
protected filterDownloadedStatus(status: TDownloadStatus): TDownloadedStatus | null {
protected filterDownloadedStatus(status: DownloadStatus): DownloadedStatus | null {
return status === DownloadStatus.NOT_DOWNLOADABLE || status === DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED ?
null : status;
}
@ -796,7 +796,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
result.total++;
} catch (error) {
const packageId = CoreFilepool.getPackageId(handler.component, module.id);
const cacheStatus = this.statusCache.getValue<TDownloadStatus>(packageId, 'status', true);
const cacheStatus = this.statusCache.getValue<DownloadStatus>(packageId, 'status', true);
if (cacheStatus === undefined) {
throw error;
}
@ -833,7 +833,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
// Get the status from the cache.
const packageId = CoreFilepool.getPackageId(handler.component, module.id);
const status = this.statusCache.getValue<TDownloadStatus>(packageId, 'status');
const status = this.statusCache.getValue<DownloadStatus>(packageId, 'status');
if (status !== undefined && !CoreFileHelper.isStateDownloaded(status)) {
return {};
@ -1343,14 +1343,14 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
* @param sectionId Section ID of the module.
*/
updateStatusCache(
status: TDownloadStatus,
status: DownloadStatus,
component: string,
componentId?: string | number,
courseId?: number,
sectionId?: number,
): void {
const packageId = CoreFilepool.getPackageId(component, componentId);
const cachedStatus = this.statusCache.getValue<TDownloadStatus>(packageId, 'status', true);
const cachedStatus = this.statusCache.getValue<DownloadStatus>(packageId, 'status', true);
// If courseId/sectionId is set, store it.
this.storeCourseAndSection(packageId, courseId, sectionId);
@ -1489,7 +1489,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler {
* @param canCheck Whether the site allows checking for updates. This parameter was deprecated since app 4.0.
* @returns Status to display.
*/
determineStatus?(module: CoreCourseAnyModuleData, status: TDownloadStatus, canCheck: true): TDownloadStatus;
determineStatus?(module: CoreCourseAnyModuleData, status: DownloadStatus, canCheck: true): DownloadStatus;
/**
* Get the downloaded size of a module. If not defined, we'll use getFiles to calculate it (it can be slow).
@ -1582,7 +1582,7 @@ type CourseUpdates = Record<number, false | CheckUpdatesWSInstance>;
*/
export type CoreCourseModulesStatus = {
total: number; // Number of modules.
status: TDownloadStatus; // Status of the list of modules.
status: DownloadStatus; // Status of the list of modules.
[DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED]: CoreCourseModuleData[]; // Modules with state NOT_DOWNLOADED.
[DownloadStatus.DOWNLOADED]: CoreCourseModuleData[]; // Modules with state DOWNLOADED.
[DownloadStatus.DOWNLOADING]: CoreCourseModuleData[]; // Modules with state DOWNLOADING.

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
import { Component, ElementRef, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
import { CoreCourseProvider, CoreCourse } from '@features/course/services/course';
import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/services/course-helper';
@ -60,7 +60,7 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On
progress = -1;
completionUserTracked: boolean | undefined = false;
protected courseStatus: TDownloadStatus = DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED;
protected courseStatus: DownloadStatus = DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED;
protected isDestroyed = false;
protected courseStatusObserver?: CoreEventObserver;
@ -211,7 +211,7 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On
*
* @param status Status to show.
*/
protected updateCourseStatus(status: TDownloadStatus): void {
protected updateCourseStatus(status: DownloadStatus): void {
const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status);
this.courseStatus = status;

View File

@ -24,7 +24,7 @@ import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreH5P } from '@features/h5p/services/h5p';
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
import { CoreSite } from '@classes/sites/site';
import { CoreLogger } from '@singletons/logger';
import { CoreH5PCore, CoreH5PDisplayOptions } from '../../classes/core';
@ -100,7 +100,7 @@ export class CoreH5PIframeComponent implements OnChanges, OnDestroy {
*/
protected async play(): Promise<void> {
let localUrl: string | undefined;
let state: TDownloadStatus;
let state: DownloadStatus;
this.onlinePlayerUrl = this.onlinePlayerUrl || CoreH5P.h5pPlayer.calculateOnlinePlayerUrl(
this.site.getURL(),
this.fileUrl || '',

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
import { CoreAppSchema } from '@services/app';
import { CoreSiteSchema } from '@services/sites';
@ -315,12 +315,12 @@ export type CoreFilepoolPackageEntry = {
/**
* Package status.
*/
status?: TDownloadStatus;
status?: DownloadStatus;
/**
* Package previous status.
*/
previous?: TDownloadStatus;
previous?: DownloadStatus;
/**
* Timestamp when this package was updated.

View File

@ -23,7 +23,7 @@ import { CoreWS, CoreWSFile } from '@services/ws';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils, CoreUtilsOpenFileOptions, OpenFileAction } from '@services/utils/utils';
import { CoreConstants, DownloadStatus, TDownloadStatus } from '@/core/constants';
import { CoreConstants, DownloadStatus } from '@/core/constants';
import { CoreError } from '@classes/errors/error';
import { makeSingleton, Translate } from '@singletons';
import { CoreNetworkError } from '@classes/errors/network-error';
@ -63,7 +63,7 @@ export class CoreFileHelperProvider {
file: CoreWSFile,
component?: string,
componentId?: string | number,
state?: TDownloadStatus,
state?: DownloadStatus,
onProgress?: CoreFileHelperOnProgress,
siteId?: string,
options: CoreUtilsOpenFileOptions = {},
@ -150,7 +150,7 @@ export class CoreFileHelperProvider {
component?: string,
componentId?: string | number,
timemodified?: number,
state?: TDownloadStatus,
state?: DownloadStatus,
onProgress?: CoreFileHelperOnProgress,
siteId?: string,
options: CoreUtilsOpenFileOptions = {},
@ -304,7 +304,7 @@ export class CoreFileHelperProvider {
* @param state The state to check.
* @returns If file has been downloaded (or outdated).
*/
isStateDownloaded(state: TDownloadStatus): boolean {
isStateDownloaded(state: DownloadStatus): boolean {
return state === DownloadStatus.DOWNLOADED || state === DownloadStatus.OUTDATED;
}

View File

@ -29,7 +29,7 @@ import { CoreTimeUtils } from '@services/utils/time';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils, CoreUtilsOpenFileOptions } from '@services/utils/utils';
import { CoreError } from '@classes/errors/error';
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
import { DownloadStatus } from '@/core/constants';
import { ApplicationInit, makeSingleton, NgZone, Translate } from '@singletons';
import { CoreLogger } from '@singletons/logger';
import {
@ -686,7 +686,7 @@ export class CoreFilepoolProvider {
* @param packageStatus Status of one of the packages.
* @returns New status for the list of packages;
*/
determinePackagesStatus(current: TDownloadStatus, packageStatus: TDownloadStatus): TDownloadStatus {
determinePackagesStatus(current: DownloadStatus, packageStatus: DownloadStatus): DownloadStatus {
if (!current) {
current = DownloadStatus.NOT_DOWNLOADABLE;
}
@ -1525,7 +1525,7 @@ export class CoreFilepoolProvider {
timemodified: number = 0,
filePath?: string,
revision?: number,
): Promise<TDownloadStatus> {
): Promise<DownloadStatus> {
let file: CoreWSFile;
try {
@ -1878,7 +1878,7 @@ export class CoreFilepoolProvider {
* @param componentId An ID to use in conjunction with the component.
* @returns Promise resolved with the status.
*/
async getPackagePreviousStatus(siteId: string, component: string, componentId?: string | number): Promise<TDownloadStatus> {
async getPackagePreviousStatus(siteId: string, component: string, componentId?: string | number): Promise<DownloadStatus> {
try {
const entry = await this.getPackageData(siteId, component, componentId);
@ -1896,7 +1896,7 @@ export class CoreFilepoolProvider {
* @param componentId An ID to use in conjunction with the component.
* @returns Promise resolved with the status.
*/
async getPackageStatus(siteId: string, component: string, componentId?: string | number): Promise<TDownloadStatus> {
async getPackageStatus(siteId: string, component: string, componentId?: string | number): Promise<DownloadStatus> {
try {
const entry = await this.getPackageData(siteId, component, componentId);
@ -2830,7 +2830,7 @@ export class CoreFilepoolProvider {
* @param componentId An ID to use in conjunction with the component.
* @returns Promise resolved when the status is changed. Resolve param: new status.
*/
async setPackagePreviousStatus(siteId: string, component: string, componentId?: string | number): Promise<TDownloadStatus> {
async setPackagePreviousStatus(siteId: string, component: string, componentId?: string | number): Promise<DownloadStatus> {
componentId = this.fixComponentId(componentId);
this.logger.debug(`Set previous status for package ${component} ${componentId}`);
@ -2909,7 +2909,7 @@ export class CoreFilepoolProvider {
*/
async storePackageStatus(
siteId: string,
status: TDownloadStatus,
status: DownloadStatus,
component: string,
componentId?: string | number,
extra?: string,
@ -2926,7 +2926,7 @@ export class CoreFilepoolProvider {
downloadTime = CoreTimeUtils.timestamp();
}
let previousStatus: TDownloadStatus | undefined;
let previousStatus: DownloadStatus | undefined;
// Search current status to set it as previous status.
try {
const entry = await this.packagesTables[siteId].getOneByPrimaryKey({ id: packageId });
@ -3075,7 +3075,7 @@ export class CoreFilepoolProvider {
*/
protected triggerPackageStatusChanged(
siteId: string,
status: TDownloadStatus,
status: DownloadStatus,
component: string,
componentId?: string | number,
): void {

View File

@ -21,7 +21,7 @@ import { CoreRedirectPayload } from '@services/navigator';
import { CoreCourseModuleCompletionData } from '@features/course/services/course-helper';
import { CoreScreenOrientation } from '@services/screen';
import { CoreSiteInfoResponse, CoreSitePublicConfigResponse } from '@classes/sites/unauthenticated-site';
import { TDownloadStatus } from '../constants';
import { DownloadStatus } from '../constants';
/**
* Observer instance to stop listening to an event.
@ -327,7 +327,7 @@ export type CoreEventLoadingChangedData = {
*/
export type CoreEventCourseStatusChanged = {
courseId: number; // Course Id.
status: TDownloadStatus;
status: DownloadStatus;
};
/**
@ -336,7 +336,7 @@ export type CoreEventCourseStatusChanged = {
export type CoreEventPackageStatusChanged = {
component: string;
componentId: string | number;
status: TDownloadStatus;
status: DownloadStatus;
};
/**