MOBILE-4470 core: Make DownloadStatus types match const names
parent
99b3f3db52
commit
8b2b130e14
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// 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 { Component, Input, ViewChild, ElementRef, OnInit, OnDestroy, Optional } from '@angular/core';
|
||||||
|
|
||||||
import { CoreTabsComponent } from '@components/tabs/tabs';
|
import { CoreTabsComponent } from '@components/tabs/tabs';
|
||||||
|
@ -575,7 +575,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
protected showStatus(status: TDownloadStatus): void {
|
protected showStatus(status: DownloadStatus): void {
|
||||||
this.showSpinner = status === DownloadStatus.DOWNLOADING;
|
this.showSpinner = status === DownloadStatus.DOWNLOADING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
|
import { DownloadStatus } from '@/core/constants';
|
||||||
import { safeNumber, SafeNumber } from '@/core/utils/types';
|
import { safeNumber, SafeNumber } from '@/core/utils/types';
|
||||||
import { Component, OnDestroy, OnInit, Optional } from '@angular/core';
|
import { Component, OnDestroy, OnInit, Optional } from '@angular/core';
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
* @param status The current status.
|
* @param status The current status.
|
||||||
* @param previousStatus The previous status. If not defined, there is no previous 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;
|
this.showStatusSpinner = status === DownloadStatus.DOWNLOADING;
|
||||||
|
|
||||||
if (status === DownloadStatus.DOWNLOADED && previousStatus === DownloadStatus.DOWNLOADING) {
|
if (status === DownloadStatus.DOWNLOADED && previousStatus === DownloadStatus.DOWNLOADING) {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
|
import { DownloadStatus } from '@/core/constants';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
|
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
|
||||||
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/course';
|
||||||
|
@ -36,7 +36,7 @@ export class AddonModResourcePrefetchHandlerService extends CoreCourseResourcePr
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
determineStatus(module: CoreCourseAnyModuleData, status: TDownloadStatus): TDownloadStatus {
|
determineStatus(module: CoreCourseAnyModuleData, status: DownloadStatus): DownloadStatus {
|
||||||
if (status === DownloadStatus.DOWNLOADED && module) {
|
if (status === DownloadStatus.DOWNLOADED && module) {
|
||||||
// If the main file is an external file, always display the module as outdated.
|
// If the main file is an external file, always display the module as outdated.
|
||||||
if ('contentsinfo' in module && module.contentsinfo) {
|
if ('contentsinfo' in module && module.contentsinfo) {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
|
import { DownloadStatus } from '@/core/constants';
|
||||||
import { Component, Input, OnInit, Optional } from '@angular/core';
|
import { Component, Input, OnInit, Optional } from '@angular/core';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component';
|
import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component';
|
||||||
|
@ -578,7 +578,7 @@ export class AddonModScormIndexComponent extends CoreCourseModuleMainActivityCom
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
protected async showStatus(status: TDownloadStatus): Promise<void> {
|
protected async showStatus(status: DownloadStatus): Promise<void> {
|
||||||
|
|
||||||
if (status === DownloadStatus.OUTDATED && this.scorm) {
|
if (status === DownloadStatus.OUTDATED && this.scorm) {
|
||||||
// Only show the outdated message if the file should be downloaded.
|
// Only show the outdated message if the file should be downloaded.
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// 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 { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { CoreCourse, CoreCourseProvider } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseProvider } from '@features/course/services/course';
|
||||||
import {
|
import {
|
||||||
|
@ -607,7 +607,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy {
|
||||||
* @param module Module to update.
|
* @param module Module to update.
|
||||||
* @param status Module status.
|
* @param status Module status.
|
||||||
*/
|
*/
|
||||||
protected updateModuleStatus(module: AddonStorageManagerModule, status: TDownloadStatus): void {
|
protected updateModuleStatus(module: AddonStorageManagerModule, status: DownloadStatus): void {
|
||||||
if (!status) {
|
if (!status) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -649,7 +649,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy {
|
||||||
*
|
*
|
||||||
* @param status Status to show.
|
* @param status Status to show.
|
||||||
*/
|
*/
|
||||||
protected updateCourseStatus(status: TDownloadStatus): void {
|
protected updateCourseStatus(status: DownloadStatus): void {
|
||||||
const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status);
|
const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status);
|
||||||
|
|
||||||
this.prefetchCourseData.status = statusData.status;
|
this.prefetchCourseData.status = statusData.status;
|
||||||
|
@ -758,5 +758,5 @@ type AddonStorageManagerModule = CoreCourseModuleData & {
|
||||||
calculatingSize: boolean;
|
calculatingSize: boolean;
|
||||||
prefetchHandler?: CoreCourseModulePrefetchHandler;
|
prefetchHandler?: CoreCourseModulePrefetchHandler;
|
||||||
spinner?: boolean;
|
spinner?: boolean;
|
||||||
downloadStatus?: TDownloadStatus;
|
downloadStatus?: DownloadStatus;
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
|
import { DownloadStatus } from '@/core/constants';
|
||||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { CoreCourse, CoreCourseProvider } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseProvider } from '@features/course/services/course';
|
||||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||||
|
@ -175,7 +175,7 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy
|
||||||
*
|
*
|
||||||
* @param courseId Updated course id.
|
* @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) {
|
if (courseId == CoreCourseProvider.ALL_COURSES_CLEARED) {
|
||||||
this.setDownloadedCourses([]);
|
this.setDownloadedCourses([]);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||||
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
|
import { DownloadStatus } from '@/core/constants';
|
||||||
import { CoreAnimations } from '@components/animations';
|
import { CoreAnimations } from '@components/animations';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +31,7 @@ import { CoreAnimations } from '@components/animations';
|
||||||
})
|
})
|
||||||
export class CoreDownloadRefreshComponent {
|
export class CoreDownloadRefreshComponent {
|
||||||
|
|
||||||
@Input() status?: TDownloadStatus; // Download status.
|
@Input() status?: DownloadStatus; // Download status.
|
||||||
@Input() statusTranslatable?: string; // Download status translatable string.
|
@Input() statusTranslatable?: string; // Download status translatable string.
|
||||||
@Input() enabled = false; // Whether the download is enabled.
|
@Input() enabled = false; // Whether the download is enabled.
|
||||||
@Input() loading = true; // Force loading status when is not downloading.
|
@Input() loading = true; // Force loading status when is not downloading.
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||||
import { CoreUrlUtils } from '@services/utils/url';
|
import { CoreUrlUtils } from '@services/utils/url';
|
||||||
import { CoreUtils, CoreUtilsOpenFileOptions, OpenFileAction } from '@services/utils/utils';
|
import { CoreUtils, CoreUtilsOpenFileOptions, OpenFileAction } from '@services/utils/utils';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
import { DownloadStatus, TDownloadStatus } from '@/core/constants';
|
import { DownloadStatus } from '@/core/constants';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { CoreWSFile } from '@services/ws';
|
import { CoreWSFile } from '@services/ws';
|
||||||
import { CorePlatform } from '@services/platform';
|
import { CorePlatform } from '@services/platform';
|
||||||
|
@ -53,7 +53,7 @@ export class CoreFileComponent implements OnInit, OnDestroy {
|
||||||
fileIcon?: string;
|
fileIcon?: string;
|
||||||
fileName!: string;
|
fileName!: string;
|
||||||
fileSizeReadable?: string;
|
fileSizeReadable?: string;
|
||||||
state?: TDownloadStatus;
|
state?: DownloadStatus;
|
||||||
timemodified!: number;
|
timemodified!: number;
|
||||||
isIOS = false;
|
isIOS = false;
|
||||||
openButtonIcon = '';
|
openButtonIcon = '';
|
||||||
|
|
|
@ -46,7 +46,7 @@ export const enum ModPurpose {
|
||||||
MOD_PURPOSE_OTHER = 'other',
|
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.
|
* Possible statuses for downloaded modules/files.
|
||||||
*/
|
*/
|
||||||
|
@ -55,6 +55,7 @@ export const DownloadedStatus = {
|
||||||
DOWNLOADING: 'downloading',
|
DOWNLOADING: 'downloading',
|
||||||
OUTDATED: 'outdated',
|
OUTDATED: 'outdated',
|
||||||
} as const;
|
} as const;
|
||||||
|
export type DownloadedStatus = typeof DownloadedStatus[keyof typeof DownloadedStatus];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Possible statuses for not downloaded modules/files.
|
* Possible statuses for not downloaded modules/files.
|
||||||
|
@ -63,6 +64,7 @@ export const NotDownloadedStatus = {
|
||||||
DOWNLOADABLE_NOT_DOWNLOADED: 'notdownloaded',
|
DOWNLOADABLE_NOT_DOWNLOADED: 'notdownloaded',
|
||||||
NOT_DOWNLOADABLE: 'notdownloadable',
|
NOT_DOWNLOADABLE: 'notdownloadable',
|
||||||
} as const;
|
} as const;
|
||||||
|
export type NotDownloadedStatus = typeof NotDownloadedStatus[keyof typeof NotDownloadedStatus];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Possible statuses for modules regarding download.
|
* Possible statuses for modules regarding download.
|
||||||
|
@ -71,12 +73,8 @@ export const DownloadStatus = {
|
||||||
...DownloadedStatus,
|
...DownloadedStatus,
|
||||||
...NotDownloadedStatus,
|
...NotDownloadedStatus,
|
||||||
} as const;
|
} as const;
|
||||||
|
export type DownloadStatus = typeof DownloadStatus[keyof typeof DownloadStatus];
|
||||||
export type TDownloadedStatus = typeof DownloadedStatus[keyof typeof DownloadedStatus];
|
/* eslint-enable @typescript-eslint/naming-convention, @typescript-eslint/no-redeclare */
|
||||||
export type TNotDownloadedStatus = typeof NotDownloadedStatus[keyof typeof NotDownloadedStatus];
|
|
||||||
export type TDownloadStatus = typeof DownloadStatus[keyof typeof DownloadStatus];
|
|
||||||
|
|
||||||
/* eslint-enable @typescript-eslint/naming-convention */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static class to contain all the core constants.
|
* Static class to contain all the core constants.
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// 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 { OnInit, OnDestroy, Input, Output, EventEmitter, Component, Optional, Inject } from '@angular/core';
|
||||||
import { CoreAnyError } from '@classes/errors/error';
|
import { CoreAnyError } from '@classes/errors/error';
|
||||||
import { CoreNetwork } from '@services/network';
|
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 isCurrentView = false; // Whether the component is in the current view.
|
||||||
protected siteId?: string; // Current Site ID.
|
protected siteId?: string; // Current Site ID.
|
||||||
protected statusObserver?: CoreEventObserver; // Observer of package status. Only if setStatusListener is called.
|
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.
|
downloadTimeReadable?: string; // Last download time in a readable format. Only if setStatusListener is called.
|
||||||
|
|
||||||
protected completionObserver?: CoreEventObserver;
|
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.
|
* @param previousStatus The previous status. If not defined, there is no previous status.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// 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.
|
// To be overridden.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ import {
|
||||||
CoreCourseModulePrefetchDelegate,
|
CoreCourseModulePrefetchDelegate,
|
||||||
CoreCourseModulePrefetchHandler,
|
CoreCourseModulePrefetchHandler,
|
||||||
} from '@features/course/services/module-prefetch-delegate';
|
} 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 { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
|
||||||
*
|
*
|
||||||
* @param prefetchStatus Module status.
|
* @param prefetchStatus Module status.
|
||||||
*/
|
*/
|
||||||
protected updateModuleStatus(prefetchStatus: TDownloadStatus | null): void {
|
protected updateModuleStatus(prefetchStatus: DownloadStatus | null): void {
|
||||||
if (!prefetchStatus) {
|
if (!prefetchStatus) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import {
|
||||||
CoreCourseModuleCompletionStatus,
|
CoreCourseModuleCompletionStatus,
|
||||||
CoreCourseGetContentsWSModule,
|
CoreCourseGetContentsWSModule,
|
||||||
} from './course';
|
} from './course';
|
||||||
import { CoreConstants, DownloadStatus, TDownloadStatus, ContextLevel } from '@/core/constants';
|
import { CoreConstants, DownloadStatus, ContextLevel } from '@/core/constants';
|
||||||
import { CoreLogger } from '@singletons/logger';
|
import { CoreLogger } from '@singletons/logger';
|
||||||
import { ApplicationInit, makeSingleton, Translate } from '@singletons';
|
import { ApplicationInit, makeSingleton, Translate } from '@singletons';
|
||||||
import { CoreFilepool } from '@services/filepool';
|
import { CoreFilepool } from '@services/filepool';
|
||||||
|
@ -82,7 +82,7 @@ import { LazyRoutesModule } from '@/app/app-routing.module';
|
||||||
export type CoreCourseModulePrefetchInfo = CoreCourseModulePackageLastDownloaded & {
|
export type CoreCourseModulePrefetchInfo = CoreCourseModulePackageLastDownloaded & {
|
||||||
size: number; // Downloaded size.
|
size: number; // Downloaded size.
|
||||||
sizeReadable: string; // Downloadable size in a readable format.
|
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.
|
statusIcon?: string; // Icon's name of the module status.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ export type CoreCourseCoursesProgress = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CorePrefetchStatusInfo = {
|
export type CorePrefetchStatusInfo = {
|
||||||
status: TDownloadStatus; // Status of the prefetch.
|
status: DownloadStatus; // Status of the prefetch.
|
||||||
statusTranslatable: string; // Status translatable string.
|
statusTranslatable: string; // Status translatable string.
|
||||||
icon: string; // Icon based on the status.
|
icon: string; // Icon based on the status.
|
||||||
loading: boolean; // If it's a loading status.
|
loading: boolean; // If it's a loading status.
|
||||||
|
@ -328,7 +328,7 @@ export class CoreCourseHelperProvider {
|
||||||
checkUpdates: boolean = true,
|
checkUpdates: boolean = true,
|
||||||
): Promise<CoreCourseSectionWithStatus[]> {
|
): Promise<CoreCourseSectionWithStatus[]> {
|
||||||
let allSectionsSection: CoreCourseSectionWithStatus | undefined;
|
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) => {
|
const promises = sections.map(async (section: CoreCourseSectionWithStatus) => {
|
||||||
section.isCalculating = true;
|
section.isCalculating = true;
|
||||||
|
@ -632,9 +632,9 @@ export class CoreCourseHelperProvider {
|
||||||
* @param courses Courses
|
* @param courses Courses
|
||||||
* @returns Promise resolved with the status.
|
* @returns Promise resolved with the status.
|
||||||
*/
|
*/
|
||||||
async determineCoursesStatus(courses: CoreCourseBasicData[]): Promise<TDownloadStatus> {
|
async determineCoursesStatus(courses: CoreCourseBasicData[]): Promise<DownloadStatus> {
|
||||||
// Get the status of each course.
|
// Get the status of each course.
|
||||||
const promises: Promise<TDownloadStatus>[] = [];
|
const promises: Promise<DownloadStatus>[] = [];
|
||||||
const siteId = CoreSites.getCurrentSiteId();
|
const siteId = CoreSites.getCurrentSiteId();
|
||||||
|
|
||||||
courses.forEach((course) => {
|
courses.forEach((course) => {
|
||||||
|
@ -817,7 +817,7 @@ export class CoreCourseHelperProvider {
|
||||||
files?: CoreCourseModuleContentFile[],
|
files?: CoreCourseModuleContentFile[],
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
options: CoreUtilsOpenFileOptions = {},
|
options: CoreUtilsOpenFileOptions = {},
|
||||||
): Promise<{ fixedUrl: string; path: string; status?: TDownloadStatus }> {
|
): Promise<{ fixedUrl: string; path: string; status?: DownloadStatus }> {
|
||||||
|
|
||||||
siteId = siteId || CoreSites.getCurrentSiteId();
|
siteId = siteId || CoreSites.getCurrentSiteId();
|
||||||
|
|
||||||
|
@ -910,7 +910,7 @@ export class CoreCourseHelperProvider {
|
||||||
courseId: number,
|
courseId: number,
|
||||||
fixedUrl: string,
|
fixedUrl: string,
|
||||||
files: CoreCourseModuleContentFile[],
|
files: CoreCourseModuleContentFile[],
|
||||||
status: TDownloadStatus,
|
status: DownloadStatus,
|
||||||
component?: string,
|
component?: string,
|
||||||
componentId?: string | number,
|
componentId?: string | number,
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
|
@ -1239,7 +1239,7 @@ export class CoreCourseHelperProvider {
|
||||||
* @param status Course status.
|
* @param status Course status.
|
||||||
* @returns Prefetch status info.
|
* @returns Prefetch status info.
|
||||||
*/
|
*/
|
||||||
getCoursePrefetchStatusInfo(status: TDownloadStatus): CorePrefetchStatusInfo {
|
getCoursePrefetchStatusInfo(status: DownloadStatus): CorePrefetchStatusInfo {
|
||||||
const prefetchStatus: CorePrefetchStatusInfo = {
|
const prefetchStatus: CorePrefetchStatusInfo = {
|
||||||
status: status,
|
status: status,
|
||||||
icon: this.getPrefetchStatusIcon(status, false),
|
icon: this.getPrefetchStatusIcon(status, false),
|
||||||
|
@ -1266,7 +1266,7 @@ export class CoreCourseHelperProvider {
|
||||||
* @param status Courses status.
|
* @param status Courses status.
|
||||||
* @returns Prefetch status info.
|
* @returns Prefetch status info.
|
||||||
*/
|
*/
|
||||||
getCoursesPrefetchStatusInfo(status: TDownloadStatus): CorePrefetchStatusInfo {
|
getCoursesPrefetchStatusInfo(status: DownloadStatus): CorePrefetchStatusInfo {
|
||||||
const prefetchStatus: CorePrefetchStatusInfo = {
|
const prefetchStatus: CorePrefetchStatusInfo = {
|
||||||
status: status,
|
status: status,
|
||||||
icon: this.getPrefetchStatusIcon(status, false),
|
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.
|
* @param trustDownload True to show download success, false to show an outdated status when downloaded.
|
||||||
* @returns Icon name.
|
* @returns Icon name.
|
||||||
*/
|
*/
|
||||||
getPrefetchStatusIcon(status: TDownloadStatus, trustDownload: boolean = false): string {
|
getPrefetchStatusIcon(status: DownloadStatus, trustDownload: boolean = false): string {
|
||||||
if (status === DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED) {
|
if (status === DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED) {
|
||||||
return CoreConstants.ICON_NOT_DOWNLOADED;
|
return CoreConstants.ICON_NOT_DOWNLOADED;
|
||||||
}
|
}
|
||||||
|
@ -1714,7 +1714,7 @@ export class CoreCourseHelperProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download all the sections except "All sections".
|
// Download all the sections except "All sections".
|
||||||
let allSectionsStatus = DownloadStatus.NOT_DOWNLOADABLE as TDownloadStatus;
|
let allSectionsStatus = DownloadStatus.NOT_DOWNLOADABLE as DownloadStatus;
|
||||||
|
|
||||||
section.isDownloading = true;
|
section.isDownloading = true;
|
||||||
const promises = sections.map(async (section) => {
|
const promises = sections.map(async (section) => {
|
||||||
|
@ -2073,7 +2073,7 @@ export type CoreCourseSection = CoreCourseWSSection & {
|
||||||
* Section with data about prefetch.
|
* Section with data about prefetch.
|
||||||
*/
|
*/
|
||||||
export type CoreCourseSectionWithStatus = CoreCourseSection & {
|
export type CoreCourseSectionWithStatus = CoreCourseSection & {
|
||||||
downloadStatus?: TDownloadStatus; // Section status.
|
downloadStatus?: DownloadStatus; // Section status.
|
||||||
isDownloading?: boolean; // Whether section is being downloaded.
|
isDownloading?: boolean; // Whether section is being downloaded.
|
||||||
total?: number; // Total of modules being downloaded.
|
total?: number; // Total of modules being downloaded.
|
||||||
count?: number; // Number of downloaded modules.
|
count?: number; // Number of downloaded modules.
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { CoreSitesCommonWSOptions, CoreSites, CoreSitesReadingStrategy } from '@
|
||||||
import { CoreTimeUtils } from '@services/utils/time';
|
import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreSite } from '@classes/sites/site';
|
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 { makeSingleton, Translate } from '@singletons';
|
||||||
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ export class CoreCourseProvider {
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @returns Promise resolved with the status.
|
* @returns Promise resolved with the status.
|
||||||
*/
|
*/
|
||||||
async getCourseStatus(courseId: number, siteId?: string): Promise<TDownloadStatus> {
|
async getCourseStatus(courseId: number, siteId?: string): Promise<DownloadStatus> {
|
||||||
try {
|
try {
|
||||||
const entry = await this.getCourseStatusData(courseId, siteId);
|
const entry = await this.getCourseStatusData(courseId, siteId);
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ export class CoreCourseProvider {
|
||||||
* @returns Resolves with an array containing downloaded course ids.
|
* @returns Resolves with an array containing downloaded course ids.
|
||||||
*/
|
*/
|
||||||
async getDownloadedCourseIds(siteId?: string): Promise<number[]> {
|
async getDownloadedCourseIds(siteId?: string): Promise<number[]> {
|
||||||
const downloadedStatuses: TDownloadStatus[] =
|
const downloadedStatuses: DownloadStatus[] =
|
||||||
[DownloadStatus.DOWNLOADED, DownloadStatus.DOWNLOADING, DownloadStatus.OUTDATED];
|
[DownloadStatus.DOWNLOADED, DownloadStatus.DOWNLOADING, DownloadStatus.OUTDATED];
|
||||||
const site = await CoreSites.getSite(siteId);
|
const site = await CoreSites.getSite(siteId);
|
||||||
const entries = await this.statusTables[site.getId()].getManyWhere({
|
const entries = await this.statusTables[site.getId()].getManyWhere({
|
||||||
|
@ -1403,7 +1403,7 @@ export class CoreCourseProvider {
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @returns Promise resolved when the status is changed. Resolve param: new status.
|
* @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();
|
siteId = siteId || CoreSites.getCurrentSiteId();
|
||||||
|
|
||||||
this.logger.debug(`Set previous status for course ${courseId} in site ${siteId}`);
|
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.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @returns Promise resolved when the status is stored.
|
* @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();
|
siteId = siteId || CoreSites.getCurrentSiteId();
|
||||||
|
|
||||||
this.logger.debug(`Set status '${status}' for course ${courseId} in site ${siteId}`);
|
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);
|
const site = await CoreSites.getSite(siteId);
|
||||||
let downloadTime = 0;
|
let downloadTime = 0;
|
||||||
let previousDownloadTime = 0;
|
let previousDownloadTime = 0;
|
||||||
let previousStatus: TDownloadStatus | undefined;
|
let previousStatus: DownloadStatus | undefined;
|
||||||
|
|
||||||
if (status === DownloadStatus.DOWNLOADING) {
|
if (status === DownloadStatus.DOWNLOADING) {
|
||||||
// Set download time if course is now downloading.
|
// Set download time if course is now downloading.
|
||||||
|
@ -1534,7 +1534,7 @@ export class CoreCourseProvider {
|
||||||
* @param status New course status.
|
* @param status New course status.
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @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, {
|
CoreEvents.trigger(CoreEvents.COURSE_STATUS_CHANGED, {
|
||||||
courseId: courseId,
|
courseId: courseId,
|
||||||
status: status,
|
status: status,
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { TDownloadStatus } from '@/core/constants';
|
import { DownloadStatus } from '@/core/constants';
|
||||||
import { CoreSiteSchema } from '@services/sites';
|
import { CoreSiteSchema } from '@services/sites';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,8 +121,8 @@ export const OFFLINE_SITE_SCHEMA: CoreSiteSchema = {
|
||||||
|
|
||||||
export type CoreCourseStatusDBRecord = {
|
export type CoreCourseStatusDBRecord = {
|
||||||
id: number;
|
id: number;
|
||||||
status: TDownloadStatus;
|
status: DownloadStatus;
|
||||||
previous: TDownloadStatus | undefined;
|
previous: DownloadStatus | undefined;
|
||||||
updated: number;
|
updated: number;
|
||||||
downloadTime: number;
|
downloadTime: number;
|
||||||
previousDownloadTime: number;
|
previousDownloadTime: number;
|
||||||
|
|
|
@ -25,7 +25,7 @@ import { makeSingleton } from '@singletons';
|
||||||
import { CoreCourseModuleData } from './course-helper';
|
import { CoreCourseModuleData } from './course-helper';
|
||||||
import { CoreNavigationOptions } from '@services/navigator';
|
import { CoreNavigationOptions } from '@services/navigator';
|
||||||
import { CoreIonicColorNames } from '@singletons/colors';
|
import { CoreIonicColorNames } from '@singletons/colors';
|
||||||
import { TDownloadStatus } from '@/core/constants';
|
import { DownloadStatus } from '@/core/constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface that all course module handlers must implement.
|
* Interface that all course module handlers must implement.
|
||||||
|
@ -223,7 +223,7 @@ export interface CoreCourseModuleHandlerData {
|
||||||
*
|
*
|
||||||
* @param status Module status.
|
* @param status Module status.
|
||||||
*/
|
*/
|
||||||
updateStatus?(status: TDownloadStatus): void;
|
updateStatus?(status: DownloadStatus): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On Destroy function in case it's needed.
|
* On Destroy function in case it's needed.
|
||||||
|
|
|
@ -25,7 +25,7 @@ import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseModuleContentFile } from './course';
|
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseModuleContentFile } from './course';
|
||||||
import { CoreCache } from '@classes/cache';
|
import { CoreCache } from '@classes/cache';
|
||||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
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 { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreEvents, CoreEventSectionStatusChangedData } from '@singletons/events';
|
import { CoreEvents, CoreEventSectionStatusChangedData } from '@singletons/events';
|
||||||
|
@ -160,7 +160,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
* @param status Current status.
|
* @param status Current status.
|
||||||
* @returns Module status.
|
* @returns Module status.
|
||||||
*/
|
*/
|
||||||
determineModuleStatus(module: CoreCourseAnyModuleData, status: TDownloadStatus): TDownloadStatus {
|
determineModuleStatus(module: CoreCourseAnyModuleData, status: DownloadStatus): DownloadStatus {
|
||||||
const handler = this.getPrefetchHandlerFor(module.modname);
|
const handler = this.getPrefetchHandlerFor(module.modname);
|
||||||
const siteId = CoreSites.getCurrentSiteId();
|
const siteId = CoreSites.getCurrentSiteId();
|
||||||
|
|
||||||
|
@ -528,7 +528,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
updates?: CourseUpdates | false,
|
updates?: CourseUpdates | false,
|
||||||
refresh?: boolean,
|
refresh?: boolean,
|
||||||
sectionId?: number,
|
sectionId?: number,
|
||||||
): Promise<TDownloadStatus> {
|
): Promise<DownloadStatus> {
|
||||||
const handler = this.getPrefetchHandlerFor(module.modname);
|
const handler = this.getPrefetchHandlerFor(module.modname);
|
||||||
|
|
||||||
if (!handler) {
|
if (!handler) {
|
||||||
|
@ -538,7 +538,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
|
|
||||||
// Check if the status is cached.
|
// Check if the status is cached.
|
||||||
const packageId = CoreFilepool.getPackageId(handler.component, module.id);
|
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) {
|
if (!refresh && status !== undefined) {
|
||||||
this.storeCourseAndSection(packageId, courseId, sectionId);
|
this.storeCourseAndSection(packageId, courseId, sectionId);
|
||||||
|
@ -573,7 +573,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
updates?: CourseUpdates | false,
|
updates?: CourseUpdates | false,
|
||||||
refresh?: boolean,
|
refresh?: boolean,
|
||||||
sectionId?: number,
|
sectionId?: number,
|
||||||
): Promise<TDownloadedStatus | null> {
|
): Promise<DownloadedStatus | null> {
|
||||||
const handler = this.getPrefetchHandlerFor(module.modname);
|
const handler = this.getPrefetchHandlerFor(module.modname);
|
||||||
if (!handler) {
|
if (!handler) {
|
||||||
// No handler found, module not downloadable.
|
// No handler found, module not downloadable.
|
||||||
|
@ -582,7 +582,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
|
|
||||||
// Check if the status is cached.
|
// Check if the status is cached.
|
||||||
const packageId = CoreFilepool.getPackageId(handler.component, module.id);
|
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) {
|
if (!refresh && status !== undefined) {
|
||||||
this.storeCourseAndSection(packageId, courseId, sectionId);
|
this.storeCourseAndSection(packageId, courseId, sectionId);
|
||||||
|
@ -617,7 +617,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
courseId: number,
|
courseId: number,
|
||||||
updates?: CourseUpdates | false,
|
updates?: CourseUpdates | false,
|
||||||
sectionId?: number,
|
sectionId?: number,
|
||||||
): Promise<{status: TDownloadStatus; updateStatus: boolean}> {
|
): Promise<{status: DownloadStatus; updateStatus: boolean}> {
|
||||||
// Check if the module is downloadable.
|
// Check if the module is downloadable.
|
||||||
const downloadable = await this.isModuleDownloadable(module, courseId);
|
const downloadable = await this.isModuleDownloadable(module, courseId);
|
||||||
if (!downloadable) {
|
if (!downloadable) {
|
||||||
|
@ -654,7 +654,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
courseId: number,
|
courseId: number,
|
||||||
updates?: CourseUpdates | false,
|
updates?: CourseUpdates | false,
|
||||||
sectionId?: number,
|
sectionId?: number,
|
||||||
): Promise<{status: TDownloadedStatus | null; updateStatus: boolean}> {
|
): Promise<{status: DownloadedStatus | null; updateStatus: boolean}> {
|
||||||
// Get the saved package status.
|
// Get the saved package status.
|
||||||
const siteId = CoreSites.getCurrentSiteId();
|
const siteId = CoreSites.getCurrentSiteId();
|
||||||
const currentStatus = await CoreFilepool.getPackageStatus(siteId, handler.component, module.id);
|
const currentStatus = await CoreFilepool.getPackageStatus(siteId, handler.component, module.id);
|
||||||
|
@ -718,7 +718,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
} catch {
|
} catch {
|
||||||
// Error checking if module has updates.
|
// Error checking if module has updates.
|
||||||
const packageId = CoreFilepool.getPackageId(handler.component, module.id);
|
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 {
|
return {
|
||||||
status: status ? this.filterDownloadedStatus(status) : null,
|
status: status ? this.filterDownloadedStatus(status) : null,
|
||||||
|
@ -733,7 +733,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
* @param status Status.
|
* @param status Status.
|
||||||
* @returns Filtered status, null for not downloaded statuses.
|
* @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 ?
|
return status === DownloadStatus.NOT_DOWNLOADABLE || status === DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED ?
|
||||||
null : status;
|
null : status;
|
||||||
}
|
}
|
||||||
|
@ -796,7 +796,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
result.total++;
|
result.total++;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const packageId = CoreFilepool.getPackageId(handler.component, module.id);
|
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) {
|
if (cacheStatus === undefined) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
@ -833,7 +833,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
|
|
||||||
// Get the status from the cache.
|
// Get the status from the cache.
|
||||||
const packageId = CoreFilepool.getPackageId(handler.component, module.id);
|
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)) {
|
if (status !== undefined && !CoreFileHelper.isStateDownloaded(status)) {
|
||||||
return {};
|
return {};
|
||||||
|
@ -1343,14 +1343,14 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate<CoreCo
|
||||||
* @param sectionId Section ID of the module.
|
* @param sectionId Section ID of the module.
|
||||||
*/
|
*/
|
||||||
updateStatusCache(
|
updateStatusCache(
|
||||||
status: TDownloadStatus,
|
status: DownloadStatus,
|
||||||
component: string,
|
component: string,
|
||||||
componentId?: string | number,
|
componentId?: string | number,
|
||||||
courseId?: number,
|
courseId?: number,
|
||||||
sectionId?: number,
|
sectionId?: number,
|
||||||
): void {
|
): void {
|
||||||
const packageId = CoreFilepool.getPackageId(component, componentId);
|
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.
|
// If courseId/sectionId is set, store it.
|
||||||
this.storeCourseAndSection(packageId, courseId, sectionId);
|
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.
|
* @param canCheck Whether the site allows checking for updates. This parameter was deprecated since app 4.0.
|
||||||
* @returns Status to display.
|
* @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).
|
* 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 = {
|
export type CoreCourseModulesStatus = {
|
||||||
total: number; // Number of modules.
|
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.DOWNLOADABLE_NOT_DOWNLOADED]: CoreCourseModuleData[]; // Modules with state NOT_DOWNLOADED.
|
||||||
[DownloadStatus.DOWNLOADED]: CoreCourseModuleData[]; // Modules with state DOWNLOADED.
|
[DownloadStatus.DOWNLOADED]: CoreCourseModuleData[]; // Modules with state DOWNLOADED.
|
||||||
[DownloadStatus.DOWNLOADING]: CoreCourseModuleData[]; // Modules with state DOWNLOADING.
|
[DownloadStatus.DOWNLOADING]: CoreCourseModuleData[]; // Modules with state DOWNLOADING.
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// 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 { Component, ElementRef, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { CoreCourseProvider, CoreCourse } from '@features/course/services/course';
|
import { CoreCourseProvider, CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/services/course-helper';
|
import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/services/course-helper';
|
||||||
|
@ -60,7 +60,7 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On
|
||||||
progress = -1;
|
progress = -1;
|
||||||
completionUserTracked: boolean | undefined = false;
|
completionUserTracked: boolean | undefined = false;
|
||||||
|
|
||||||
protected courseStatus: TDownloadStatus = DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED;
|
protected courseStatus: DownloadStatus = DownloadStatus.DOWNLOADABLE_NOT_DOWNLOADED;
|
||||||
protected isDestroyed = false;
|
protected isDestroyed = false;
|
||||||
protected courseStatusObserver?: CoreEventObserver;
|
protected courseStatusObserver?: CoreEventObserver;
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On
|
||||||
*
|
*
|
||||||
* @param status Status to show.
|
* @param status Status to show.
|
||||||
*/
|
*/
|
||||||
protected updateCourseStatus(status: TDownloadStatus): void {
|
protected updateCourseStatus(status: DownloadStatus): void {
|
||||||
const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status);
|
const statusData = CoreCourseHelper.getCoursePrefetchStatusInfo(status);
|
||||||
|
|
||||||
this.courseStatus = status;
|
this.courseStatus = status;
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { CoreSites } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreUrlUtils } from '@services/utils/url';
|
import { CoreUrlUtils } from '@services/utils/url';
|
||||||
import { CoreH5P } from '@features/h5p/services/h5p';
|
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 { CoreSite } from '@classes/sites/site';
|
||||||
import { CoreLogger } from '@singletons/logger';
|
import { CoreLogger } from '@singletons/logger';
|
||||||
import { CoreH5PCore, CoreH5PDisplayOptions } from '../../classes/core';
|
import { CoreH5PCore, CoreH5PDisplayOptions } from '../../classes/core';
|
||||||
|
@ -100,7 +100,7 @@ export class CoreH5PIframeComponent implements OnChanges, OnDestroy {
|
||||||
*/
|
*/
|
||||||
protected async play(): Promise<void> {
|
protected async play(): Promise<void> {
|
||||||
let localUrl: string | undefined;
|
let localUrl: string | undefined;
|
||||||
let state: TDownloadStatus;
|
let state: DownloadStatus;
|
||||||
this.onlinePlayerUrl = this.onlinePlayerUrl || CoreH5P.h5pPlayer.calculateOnlinePlayerUrl(
|
this.onlinePlayerUrl = this.onlinePlayerUrl || CoreH5P.h5pPlayer.calculateOnlinePlayerUrl(
|
||||||
this.site.getURL(),
|
this.site.getURL(),
|
||||||
this.fileUrl || '',
|
this.fileUrl || '',
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { TDownloadStatus } from '@/core/constants';
|
import { DownloadStatus } from '@/core/constants';
|
||||||
import { CoreAppSchema } from '@services/app';
|
import { CoreAppSchema } from '@services/app';
|
||||||
import { CoreSiteSchema } from '@services/sites';
|
import { CoreSiteSchema } from '@services/sites';
|
||||||
|
|
||||||
|
@ -315,12 +315,12 @@ export type CoreFilepoolPackageEntry = {
|
||||||
/**
|
/**
|
||||||
* Package status.
|
* Package status.
|
||||||
*/
|
*/
|
||||||
status?: TDownloadStatus;
|
status?: DownloadStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Package previous status.
|
* Package previous status.
|
||||||
*/
|
*/
|
||||||
previous?: TDownloadStatus;
|
previous?: DownloadStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Timestamp when this package was updated.
|
* Timestamp when this package was updated.
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { CoreWS, CoreWSFile } from '@services/ws';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreUrlUtils } from '@services/utils/url';
|
import { CoreUrlUtils } from '@services/utils/url';
|
||||||
import { CoreUtils, CoreUtilsOpenFileOptions, OpenFileAction } from '@services/utils/utils';
|
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 { CoreError } from '@classes/errors/error';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
import { CoreNetworkError } from '@classes/errors/network-error';
|
import { CoreNetworkError } from '@classes/errors/network-error';
|
||||||
|
@ -63,7 +63,7 @@ export class CoreFileHelperProvider {
|
||||||
file: CoreWSFile,
|
file: CoreWSFile,
|
||||||
component?: string,
|
component?: string,
|
||||||
componentId?: string | number,
|
componentId?: string | number,
|
||||||
state?: TDownloadStatus,
|
state?: DownloadStatus,
|
||||||
onProgress?: CoreFileHelperOnProgress,
|
onProgress?: CoreFileHelperOnProgress,
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
options: CoreUtilsOpenFileOptions = {},
|
options: CoreUtilsOpenFileOptions = {},
|
||||||
|
@ -150,7 +150,7 @@ export class CoreFileHelperProvider {
|
||||||
component?: string,
|
component?: string,
|
||||||
componentId?: string | number,
|
componentId?: string | number,
|
||||||
timemodified?: number,
|
timemodified?: number,
|
||||||
state?: TDownloadStatus,
|
state?: DownloadStatus,
|
||||||
onProgress?: CoreFileHelperOnProgress,
|
onProgress?: CoreFileHelperOnProgress,
|
||||||
siteId?: string,
|
siteId?: string,
|
||||||
options: CoreUtilsOpenFileOptions = {},
|
options: CoreUtilsOpenFileOptions = {},
|
||||||
|
@ -304,7 +304,7 @@ export class CoreFileHelperProvider {
|
||||||
* @param state The state to check.
|
* @param state The state to check.
|
||||||
* @returns If file has been downloaded (or outdated).
|
* @returns If file has been downloaded (or outdated).
|
||||||
*/
|
*/
|
||||||
isStateDownloaded(state: TDownloadStatus): boolean {
|
isStateDownloaded(state: DownloadStatus): boolean {
|
||||||
return state === DownloadStatus.DOWNLOADED || state === DownloadStatus.OUTDATED;
|
return state === DownloadStatus.DOWNLOADED || state === DownloadStatus.OUTDATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import { CoreTimeUtils } from '@services/utils/time';
|
||||||
import { CoreUrlUtils } from '@services/utils/url';
|
import { CoreUrlUtils } from '@services/utils/url';
|
||||||
import { CoreUtils, CoreUtilsOpenFileOptions } from '@services/utils/utils';
|
import { CoreUtils, CoreUtilsOpenFileOptions } from '@services/utils/utils';
|
||||||
import { CoreError } from '@classes/errors/error';
|
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 { ApplicationInit, makeSingleton, NgZone, Translate } from '@singletons';
|
||||||
import { CoreLogger } from '@singletons/logger';
|
import { CoreLogger } from '@singletons/logger';
|
||||||
import {
|
import {
|
||||||
|
@ -686,7 +686,7 @@ export class CoreFilepoolProvider {
|
||||||
* @param packageStatus Status of one of the packages.
|
* @param packageStatus Status of one of the packages.
|
||||||
* @returns New status for the list of packages;
|
* @returns New status for the list of packages;
|
||||||
*/
|
*/
|
||||||
determinePackagesStatus(current: TDownloadStatus, packageStatus: TDownloadStatus): TDownloadStatus {
|
determinePackagesStatus(current: DownloadStatus, packageStatus: DownloadStatus): DownloadStatus {
|
||||||
if (!current) {
|
if (!current) {
|
||||||
current = DownloadStatus.NOT_DOWNLOADABLE;
|
current = DownloadStatus.NOT_DOWNLOADABLE;
|
||||||
}
|
}
|
||||||
|
@ -1525,7 +1525,7 @@ export class CoreFilepoolProvider {
|
||||||
timemodified: number = 0,
|
timemodified: number = 0,
|
||||||
filePath?: string,
|
filePath?: string,
|
||||||
revision?: number,
|
revision?: number,
|
||||||
): Promise<TDownloadStatus> {
|
): Promise<DownloadStatus> {
|
||||||
let file: CoreWSFile;
|
let file: CoreWSFile;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -1878,7 +1878,7 @@ export class CoreFilepoolProvider {
|
||||||
* @param componentId An ID to use in conjunction with the component.
|
* @param componentId An ID to use in conjunction with the component.
|
||||||
* @returns Promise resolved with the status.
|
* @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 {
|
try {
|
||||||
const entry = await this.getPackageData(siteId, component, componentId);
|
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.
|
* @param componentId An ID to use in conjunction with the component.
|
||||||
* @returns Promise resolved with the status.
|
* @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 {
|
try {
|
||||||
const entry = await this.getPackageData(siteId, component, componentId);
|
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.
|
* @param componentId An ID to use in conjunction with the component.
|
||||||
* @returns Promise resolved when the status is changed. Resolve param: new status.
|
* @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);
|
componentId = this.fixComponentId(componentId);
|
||||||
this.logger.debug(`Set previous status for package ${component} ${componentId}`);
|
this.logger.debug(`Set previous status for package ${component} ${componentId}`);
|
||||||
|
|
||||||
|
@ -2909,7 +2909,7 @@ export class CoreFilepoolProvider {
|
||||||
*/
|
*/
|
||||||
async storePackageStatus(
|
async storePackageStatus(
|
||||||
siteId: string,
|
siteId: string,
|
||||||
status: TDownloadStatus,
|
status: DownloadStatus,
|
||||||
component: string,
|
component: string,
|
||||||
componentId?: string | number,
|
componentId?: string | number,
|
||||||
extra?: string,
|
extra?: string,
|
||||||
|
@ -2926,7 +2926,7 @@ export class CoreFilepoolProvider {
|
||||||
downloadTime = CoreTimeUtils.timestamp();
|
downloadTime = CoreTimeUtils.timestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
let previousStatus: TDownloadStatus | undefined;
|
let previousStatus: DownloadStatus | undefined;
|
||||||
// Search current status to set it as previous status.
|
// Search current status to set it as previous status.
|
||||||
try {
|
try {
|
||||||
const entry = await this.packagesTables[siteId].getOneByPrimaryKey({ id: packageId });
|
const entry = await this.packagesTables[siteId].getOneByPrimaryKey({ id: packageId });
|
||||||
|
@ -3075,7 +3075,7 @@ export class CoreFilepoolProvider {
|
||||||
*/
|
*/
|
||||||
protected triggerPackageStatusChanged(
|
protected triggerPackageStatusChanged(
|
||||||
siteId: string,
|
siteId: string,
|
||||||
status: TDownloadStatus,
|
status: DownloadStatus,
|
||||||
component: string,
|
component: string,
|
||||||
componentId?: string | number,
|
componentId?: string | number,
|
||||||
): void {
|
): void {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { CoreRedirectPayload } from '@services/navigator';
|
||||||
import { CoreCourseModuleCompletionData } from '@features/course/services/course-helper';
|
import { CoreCourseModuleCompletionData } from '@features/course/services/course-helper';
|
||||||
import { CoreScreenOrientation } from '@services/screen';
|
import { CoreScreenOrientation } from '@services/screen';
|
||||||
import { CoreSiteInfoResponse, CoreSitePublicConfigResponse } from '@classes/sites/unauthenticated-site';
|
import { CoreSiteInfoResponse, CoreSitePublicConfigResponse } from '@classes/sites/unauthenticated-site';
|
||||||
import { TDownloadStatus } from '../constants';
|
import { DownloadStatus } from '../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Observer instance to stop listening to an event.
|
* Observer instance to stop listening to an event.
|
||||||
|
@ -327,7 +327,7 @@ export type CoreEventLoadingChangedData = {
|
||||||
*/
|
*/
|
||||||
export type CoreEventCourseStatusChanged = {
|
export type CoreEventCourseStatusChanged = {
|
||||||
courseId: number; // Course Id.
|
courseId: number; // Course Id.
|
||||||
status: TDownloadStatus;
|
status: DownloadStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -336,7 +336,7 @@ export type CoreEventCourseStatusChanged = {
|
||||||
export type CoreEventPackageStatusChanged = {
|
export type CoreEventPackageStatusChanged = {
|
||||||
component: string;
|
component: string;
|
||||||
componentId: string | number;
|
componentId: string | number;
|
||||||
status: TDownloadStatus;
|
status: DownloadStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue