From f58a3a9f4ba4e1f12143fe6a247216a48aca9f27 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 1 Feb 2021 12:28:37 +0100 Subject: [PATCH] MOBILE-3565 course: Change course type in prefetch functions --- .../classes/activity-prefetch-handler.ts | 23 ++++-- .../features/course/classes/activity-sync.ts | 6 +- .../course/classes/module-prefetch-handler.ts | 28 ++++---- src/core/features/course/services/course.ts | 11 ++- .../features/course/services/log-helper.ts | 13 ++++ .../services/module-prefetch-delegate.ts | 72 +++++++++---------- src/core/services/utils/dom.ts | 2 +- 7 files changed, 92 insertions(+), 63 deletions(-) diff --git a/src/core/features/course/classes/activity-prefetch-handler.ts b/src/core/features/course/classes/activity-prefetch-handler.ts index 1e0131086..3a0803887 100644 --- a/src/core/features/course/classes/activity-prefetch-handler.ts +++ b/src/core/features/course/classes/activity-prefetch-handler.ts @@ -18,7 +18,7 @@ import { CoreFilterHelper } from '@features/filter/services/filter-helper'; import { CoreApp } from '@services/app'; import { CoreFilepool } from '@services/filepool'; import { CoreSites } from '@services/sites'; -import { CoreCourse, CoreCourseWSModule } from '../services/course'; +import { CoreCourse, CoreCourseAnyModuleData } from '../services/course'; import { CoreCourseModulePrefetchHandlerBase } from './module-prefetch-handler'; /** @@ -41,7 +41,7 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe * @param dirPath Path of the directory where to store all the content files. * @return Promise resolved when all content is downloaded. */ - download(module: CoreCourseWSModule, courseId: number, dirPath?: string): Promise { + download(module: CoreCourseAnyModuleData, courseId: number, dirPath?: string): Promise { // Same implementation for download and prefetch. return this.prefetch(module, courseId, false, dirPath); } @@ -56,7 +56,7 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe * @return Promise resolved when done. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - async prefetch(module: CoreCourseWSModule, courseId?: number, single?: boolean, dirPath?: string): Promise { + async prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean, dirPath?: string): Promise { // To be overridden. It should call prefetchPackage return; } @@ -77,8 +77,8 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe * @return Promise resolved when the module has been downloaded. Data returned is not reliable. */ async prefetchPackage( - module: CoreCourseWSModule, - courseId: number, + module: CoreCourseAnyModuleData, + courseId: number | undefined, downloadFunction: () => Promise, siteId?: string, ): Promise { @@ -99,9 +99,18 @@ export class CoreCourseActivityPrefetchHandlerBase extends CoreCourseModulePrefe return this.addOngoingDownload(module.id, prefetchPromise, siteId); } + /** + * Change module status and call the prefetch function. + * + * @param module Module. + * @param courseId Course ID the module belongs to. + * @param downloadFn Function to perform the prefetch. Please check the documentation of prefetchFunction. + * @param siteId Site ID. If not defined, current site. + * @return Promise resolved when the module has been downloaded. Data returned is not reliable. + */ protected async changeStatusAndPrefetch( - module: CoreCourseWSModule, - courseId: number, + module: CoreCourseAnyModuleData, + courseId: number | undefined, downloadFunction: () => Promise, siteId?: string, ): Promise { diff --git a/src/core/features/course/classes/activity-sync.ts b/src/core/features/course/classes/activity-sync.ts index e00a5dc8d..f7e97c136 100644 --- a/src/core/features/course/classes/activity-sync.ts +++ b/src/core/features/course/classes/activity-sync.ts @@ -13,14 +13,14 @@ // limitations under the License. import { CoreSyncBaseProvider } from '@classes/base-sync'; -import { CoreCourseWSModule } from '../services/course'; +import { CoreCourseAnyModuleData } from '../services/course'; import { CoreCourseModulePrefetchDelegate } from '../services/module-prefetch-delegate'; import { CoreCourseModulePrefetchHandlerBase } from './module-prefetch-handler'; /** * Base class to create activity sync providers. It provides some common functions. */ -export class CoreCourseActivitySyncBaseProvider extends CoreSyncBaseProvider { +export class CoreCourseActivitySyncBaseProvider extends CoreSyncBaseProvider { /** * Conveniece function to prefetch data after an update. @@ -33,7 +33,7 @@ export class CoreCourseActivitySyncBaseProvider extends CoreSyncBaseProvider { */ async prefetchAfterUpdate( prefetchHandler: CoreCourseModulePrefetchHandlerBase, - module: CoreCourseWSModule, + module: CoreCourseAnyModuleData, courseId: number, preventDownloadRegex?: RegExp, siteId?: string, diff --git a/src/core/features/course/classes/module-prefetch-handler.ts b/src/core/features/course/classes/module-prefetch-handler.ts index 7b5e10654..6c3d48ab1 100644 --- a/src/core/features/course/classes/module-prefetch-handler.ts +++ b/src/core/features/course/classes/module-prefetch-handler.ts @@ -16,7 +16,7 @@ import { CoreFilepool } from '@services/filepool'; import { CoreFileSizeSum, CorePluginFileDelegate } from '@services/plugin-file-delegate'; import { CoreSites } from '@services/sites'; import { CoreWSExternalFile } from '@services/ws'; -import { CoreCourse, CoreCourseModuleContentFile, CoreCourseWSModule } from '../services/course'; +import { CoreCourse, CoreCourseAnyModuleData, CoreCourseModuleContentFile } from '../services/course'; import { CoreCourseModulePrefetchHandler } from '../services/module-prefetch-delegate'; /** @@ -93,7 +93,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref * @return Promise resolved when all content is downloaded. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - async download(module: CoreCourseWSModule, courseId: number, dirPath?: string): Promise { + async download(module: CoreCourseAnyModuleData, courseId: number, dirPath?: string): Promise { // To be overridden. return; } @@ -104,7 +104,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref * @param module The module object returned by WS. * @return List of files. */ - getContentDownloadableFiles(module: CoreCourseWSModule): CoreCourseModuleContentFile[] { + getContentDownloadableFiles(module: CoreCourseAnyModuleData): CoreCourseModuleContentFile[] { if (!module.contents?.length) { return []; } @@ -121,7 +121,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref * @return Promise resolved with the size. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - async getDownloadSize(module: CoreCourseWSModule, courseId: number, single?: boolean): Promise { + async getDownloadSize(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise { try { const files = await this.getFiles(module, courseId); @@ -139,7 +139,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref * @return Size, or promise resolved with the size. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - async getDownloadedSize(module: CoreCourseWSModule, courseId: number): Promise { + async getDownloadedSize(module: CoreCourseAnyModuleData, courseId: number): Promise { const siteId = CoreSites.instance.getCurrentSiteId(); return CoreFilepool.instance.getFilesSizeByComponent(siteId, this.component, module.id); @@ -154,7 +154,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref * @return Promise resolved with the list of files. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - async getFiles(module: CoreCourseWSModule, courseId: number, single?: boolean): Promise { + async getFiles(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise { // To be overridden. return []; } @@ -168,7 +168,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref * @return Promise resolved with list of intro files. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - async getIntroFiles(module: CoreCourseWSModule, courseId: number, ignoreCache?: boolean): Promise { + async getIntroFiles(module: CoreCourseAnyModuleData, courseId: number, ignoreCache?: boolean): Promise { return this.getIntroFilesFromInstance(module); } @@ -179,7 +179,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref * @param instance The instance to get the intro files (book, assign, ...). If not defined, module will be used. * @return List of intro files. */ - getIntroFilesFromInstance(module: CoreCourseWSModule, instance?: ModuleInstance): CoreWSExternalFile[] { + getIntroFilesFromInstance(module: CoreCourseAnyModuleData, instance?: ModuleInstance): CoreWSExternalFile[] { if (instance) { if (typeof instance.introfiles != 'undefined') { return instance.introfiles; @@ -188,7 +188,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref } } - if (module.description) { + if ('description' in module && module.description) { return CoreFilepool.instance.extractDownloadableFilesFromHtmlAsFakeFileObjects(module.description); } @@ -243,7 +243,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref * @return Promise resolved when invalidated. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - invalidateModule(module: CoreCourseWSModule, courseId: number): Promise { + invalidateModule(module: CoreCourseAnyModuleData, courseId: number): Promise { return CoreCourse.instance.invalidateModule(module.id); } @@ -255,7 +255,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref * @return Whether the module can be downloaded. The promise should never be rejected. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - async isDownloadable(module: CoreCourseWSModule, courseId: number): Promise { + async isDownloadable(module: CoreCourseAnyModuleData, courseId: number): Promise { // By default, mark all instances as downloadable. return true; } @@ -301,7 +301,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref * @return Promise resolved when loaded. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - async loadContents(module: CoreCourseWSModule, courseId: number, ignoreCache?: boolean): Promise { + async loadContents(module: CoreCourseAnyModuleData, courseId: number, ignoreCache?: boolean): Promise { // To be overridden. return; } @@ -316,7 +316,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref * @return Promise resolved when done. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - async prefetch(module: CoreCourseWSModule, courseId?: number, single?: boolean, dirPath?: string): Promise { + async prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean, dirPath?: string): Promise { // To be overridden. return; } @@ -329,7 +329,7 @@ export class CoreCourseModulePrefetchHandlerBase implements CoreCourseModulePref * @return Promise resolved when done. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - removeFiles(module: CoreCourseWSModule, courseId: number): Promise { + removeFiles(module: CoreCourseAnyModuleData, courseId: number): Promise { return CoreFilepool.instance.removeFilesByComponent(CoreSites.instance.getCurrentSiteId(), this.component, module.id); } diff --git a/src/core/features/course/services/course.ts b/src/core/features/course/services/course.ts index 9982e3d00..b0f743abe 100644 --- a/src/core/features/course/services/course.ts +++ b/src/core/features/course/services/course.ts @@ -851,7 +851,7 @@ export class CoreCourseProvider { * @return Promise resolved when loaded. */ async loadModuleContents( - module: CoreCourseWSModule, + module: CoreCourseAnyModuleData, courseId?: number, sectionId?: number, preferCache?: boolean, @@ -1199,6 +1199,8 @@ export class CoreCourseProvider { } +export class CoreCourse extends makeSingleton(CoreCourseProvider) {} + /** * Common options used by modules when calling a WS through CoreSite. */ @@ -1522,4 +1524,9 @@ type CoreCompletionUpdateActivityCompletionStatusManuallyWSParams = { completed: boolean; // Activity completed or not. }; -export class CoreCourse extends makeSingleton(CoreCourseProvider) {} +/** + * Any of the possible module WS data. + */ +export type CoreCourseAnyModuleData = CoreCourseWSModule | CoreCourseModuleBasicInfo & { + contents?: CoreCourseModuleContentFile[]; // Calculated in the app in loadModuleContents. +}; diff --git a/src/core/features/course/services/log-helper.ts b/src/core/features/course/services/log-helper.ts index 346bcc12d..d75121c88 100644 --- a/src/core/features/course/services/log-helper.ts +++ b/src/core/features/course/services/log-helper.ts @@ -304,6 +304,19 @@ export class CoreCourseLogHelperProvider { return this.syncLogs(unique, siteId); } + /** + * Sync the offline saved activity logs. + * + * @param component Component name. + * @param componentId Component ID. + * @param siteId Site ID. If not defined, current site. + * @return Promise resolved when done. + * @deprecated since 3.9.5. Please use syncActivity instead. + */ + syncIfNeeded(component: string, componentId: number, siteId?: string): Promise { + return this.syncActivity(component, componentId, siteId); + } + /** * Sync the offline saved activity logs. * diff --git a/src/core/features/course/services/module-prefetch-delegate.ts b/src/core/features/course/services/module-prefetch-delegate.ts index 57e6599b7..570b89f5f 100644 --- a/src/core/features/course/services/module-prefetch-delegate.ts +++ b/src/core/features/course/services/module-prefetch-delegate.ts @@ -22,7 +22,7 @@ import { CoreFilepool, CoreFilepoolComponentFileEventData } from '@services/file import { CoreSites } from '@services/sites'; import { CoreTimeUtils } from '@services/utils/time'; import { CoreUtils } from '@services/utils/utils'; -import { CoreCourse, CoreCourseModuleContentFile, CoreCourseWSModule } from './course'; +import { CoreCourse, CoreCourseAnyModuleData, CoreCourseModuleContentFile, CoreCourseWSModule } from './course'; import { CoreCache } from '@classes/cache'; import { CoreSiteWSPreSets } from '@classes/site'; import { CoreConstants } from '@/core/constants'; @@ -92,7 +92,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { + async canModuleUseCheckUpdates(module: CoreCourseAnyModuleData, courseId: number): Promise { const handler = this.getPrefetchHandlerFor(module); if (!handler) { @@ -169,7 +169,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { + async downloadModule(module: CoreCourseAnyModuleData, courseId: number, dirPath?: string): Promise { // Check if the module has a prefetch handler. const handler = this.getPrefetchHandlerFor(module); @@ -389,7 +389,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { + async getModuleDownloadSize(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise { const handler = this.getPrefetchHandlerFor(module); if (!handler) { @@ -427,7 +427,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { + async getModuleDownloadedSize(module: CoreCourseAnyModuleData, courseId: number): Promise { const handler = this.getPrefetchHandlerFor(module); if (!handler) { return 0; @@ -493,7 +493,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { + async getModuleStoredSize(module: CoreCourseAnyModuleData, courseId: number): Promise { let downloadedSize = await this.getModuleDownloadedSize(module, courseId); if (isNaN(downloadedSize)) { @@ -522,7 +522,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { const handler = this.getPrefetchHandlerFor(module); @@ -534,7 +534,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { const handler = this.getPrefetchHandlerFor(module); @@ -813,7 +813,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { - if (module.uservisible === false) { + async isModuleDownloadable(module: CoreCourseAnyModuleData, courseId: number): Promise { + if ('uservisible' in module && module.uservisible === false) { // Module isn't visible by the user, cannot be downloaded. return false; } @@ -1011,7 +1011,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { + async moduleHasUpdates(module: CoreCourseAnyModuleData, courseId: number, updates: CourseUpdates): Promise { const handler = this.getPrefetchHandlerFor(module); const moduleUpdates = updates[module.id]; @@ -1044,7 +1044,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { + async prefetchModule(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise { const handler = this.getPrefetchHandlerFor(module); if (!handler) { return; @@ -1078,18 +1078,18 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate(module: CoreCourseWSModule, courseId: number): Promise { + async syncModule(module: CoreCourseAnyModuleData, courseId: number): Promise { const handler = this.getPrefetchHandlerFor(module); if (!handler?.sync) { return; } - const result = await CoreUtils.instance.ignoreErrors(handler.sync(module, courseId)); + const result = await CoreUtils.instance.ignoreErrors(handler.sync(module, courseId)); // Always invalidate status cache for this module. We cannot know if data was sent to server or not. this.invalidateModuleStatusCache(module); - return result; + return result; } /** @@ -1181,7 +1181,7 @@ export class CoreCourseModulePrefetchDelegateService extends CoreDelegate { + async removeModuleFiles(module: CoreCourseAnyModuleData, courseId: number): Promise { const handler = this.getPrefetchHandlerFor(module); const siteId = CoreSites.instance.getCurrentSiteId(); @@ -1393,7 +1393,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * @param single True if we're downloading a single module, false if we're downloading a whole section. * @return Promise resolved with the size. */ - getDownloadSize(module: CoreCourseWSModule, courseId: number, single?: boolean): Promise; + getDownloadSize(module: CoreCourseAnyModuleData, courseId: number, single?: boolean): Promise; /** * Prefetch a module. @@ -1404,7 +1404,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * @param dirPath Path of the directory where to store all the content files. * @return Promise resolved when done. */ - prefetch(module: CoreCourseWSModule, courseId?: number, single?: boolean, dirPath?: string): Promise; + prefetch(module: CoreCourseAnyModuleData, courseId?: number, single?: boolean, dirPath?: string): Promise; /** * Download the module. @@ -1414,7 +1414,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * @param dirPath Path of the directory where to store all the content files. * @return Promise resolved when all content is downloaded. */ - download(module: CoreCourseWSModule, courseId: number, dirPath?: string): Promise; + download(module: CoreCourseAnyModuleData, courseId: number, dirPath?: string): Promise; /** * Invalidate the prefetched content. @@ -1434,7 +1434,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * @param courseId Course ID the module belongs to. * @return Whether the module can use check_updates. The promise should never be rejected. */ - canUseCheckUpdates?(module: CoreCourseWSModule, courseId: number): Promise; + canUseCheckUpdates?(module: CoreCourseAnyModuleData, courseId: number): Promise; /** * Return the status to show based on current status. E.g. a module might want to show outdated instead of downloaded. @@ -1445,7 +1445,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * @param canCheck Whether the site allows checking for updates. * @return Status to display. */ - determineStatus?(module: CoreCourseWSModule, status: string, canCheck: boolean): string; + determineStatus?(module: CoreCourseAnyModuleData, status: string, canCheck: boolean): string; /** * Get the downloaded size of a module. If not defined, we'll use getFiles to calculate it (it can be slow). @@ -1454,7 +1454,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * @param courseId Course ID the module belongs to. * @return Size, or promise resolved with the size. */ - getDownloadedSize?(module: CoreCourseWSModule, courseId: number): Promise; + getDownloadedSize?(module: CoreCourseAnyModuleData, courseId: number): Promise; /** * Get the list of files of the module. If not defined, we'll assume they are in module.contents. @@ -1463,7 +1463,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * @param courseId Course ID the module belongs to. * @return List of files, or promise resolved with the files. */ - getFiles?(module: CoreCourseWSModule, courseId: number): Promise<(CoreWSExternalFile | CoreCourseModuleContentFile)[]>; + getFiles?(module: CoreCourseAnyModuleData, courseId: number): Promise<(CoreWSExternalFile | CoreCourseModuleContentFile)[]>; /** * Check if a certain module has updates based on the result of check updates. @@ -1473,7 +1473,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * @param moduleUpdates List of updates for the module. * @return Whether the module has updates. The promise should never be rejected. */ - hasUpdates?(module: CoreCourseWSModule, courseId: number, moduleUpdates: false | CheckUpdatesWSInstance): Promise; + hasUpdates?(module: CoreCourseAnyModuleData, courseId: number, moduleUpdates: false | CheckUpdatesWSInstance): Promise; /** * Invalidate WS calls needed to determine module status (usually, to check if module is downloadable). @@ -1483,7 +1483,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * @param courseId Course ID the module belongs to. * @return Promise resolved when invalidated. */ - invalidateModule?(module: CoreCourseWSModule, courseId: number): Promise; + invalidateModule?(module: CoreCourseAnyModuleData, courseId: number): Promise; /** * Check if a module can be downloaded. If the function is not defined, we assume that all modules are downloadable. @@ -1492,7 +1492,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * @param courseId Course ID the module belongs to. * @return Whether the module can be downloaded. The promise should never be rejected. */ - isDownloadable?(module: CoreCourseWSModule, courseId: number): Promise; + isDownloadable?(module: CoreCourseAnyModuleData, courseId: number): Promise; /** * Load module contents in module.contents if they aren't loaded already. This is meant for resources. @@ -1501,7 +1501,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * @param courseId Course ID the module belongs to. * @return Promise resolved when done. */ - loadContents?(module: CoreCourseWSModule, courseId: number): Promise; + loadContents?(module: CoreCourseAnyModuleData, courseId: number): Promise; /** * Remove module downloaded files. If not defined, we'll use getFiles to remove them (slow). @@ -1510,7 +1510,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * @param courseId Course ID the module belongs to. * @return Promise resolved when done. */ - removeFiles?(module: CoreCourseWSModule, courseId: number): Promise; + removeFiles?(module: CoreCourseAnyModuleData, courseId: number): Promise; /** * Sync a module. @@ -1520,7 +1520,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { * @param siteId Site ID. If not defined, current site. * @return Promise resolved when done. */ - sync?(module: CoreCourseWSModule, courseId: number, siteId?: string): Promise; + sync?(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise; } type ToCheckList = { diff --git a/src/core/services/utils/dom.ts b/src/core/services/utils/dom.ts index 444376fa9..9455ca8dc 100644 --- a/src/core/services/utils/dom.ts +++ b/src/core/services/utils/dom.ts @@ -1726,7 +1726,7 @@ export class CoreDomUtilsProvider { * @param form Form element. * @param siteId The site affected. If not provided, no site affected. */ - triggerFormCancelledEvent(formRef: ElementRef, siteId?: string): void { + triggerFormCancelledEvent(formRef: ElementRef | HTMLFormElement | undefined, siteId?: string): void { if (!formRef) { return; }