diff --git a/src/addons/mod/data/services/data-helper.ts b/src/addons/mod/data/services/data-helper.ts index ee4ef04e3..9fc836dda 100644 --- a/src/addons/mod/data/services/data-helper.ts +++ b/src/addons/mod/data/services/data-helper.ts @@ -802,14 +802,14 @@ export class AddonModDataHelperProvider { offline: boolean, siteId?: string, ): Promise { - if (!files.length) { - return 0; - } - if (offline) { return this.storeFiles(dataId, entryId, fieldId, files, siteId); } + if (!files.length) { + return 0; + } + return CoreFileUploader.uploadOrReuploadFiles(files, AddonModDataProvider.COMPONENT, itemId, siteId); } diff --git a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts index 05a0f6218..3cc680eb7 100644 --- a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts +++ b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts @@ -332,7 +332,9 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca // Upload attachments first if any. let allowOffline = !inputData.attachmentfiles.length; try { - let attachmentsId: CoreFileUploaderStoreFilesResult | number | undefined; + let attachmentsId: number | undefined; + let storeFilesResult: CoreFileUploaderStoreFilesResult | undefined; + try { attachmentsId = await AddonModWorkshopHelper.uploadOrStoreSubmissionFiles( this.workshopId, @@ -344,7 +346,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca saveOffline = true; allowOffline = true; - attachmentsId = await AddonModWorkshopHelper.uploadOrStoreSubmissionFiles( + storeFilesResult = await AddonModWorkshopHelper.uploadOrStoreSubmissionFiles( this.workshopId, inputData.attachmentfiles, true, @@ -364,7 +366,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca this.courseId, inputData.title, inputData.content, - attachmentsId as CoreFileUploaderStoreFilesResult, + storeFilesResult, submissionId, AddonModWorkshopAction.UPDATE, ); @@ -391,7 +393,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca this.courseId, inputData.title, inputData.content, - attachmentsId as CoreFileUploaderStoreFilesResult, + storeFilesResult, undefined, AddonModWorkshopAction.ADD, ); diff --git a/src/addons/mod/workshop/services/workshop.ts b/src/addons/mod/workshop/services/workshop.ts index 7946c70c2..ba637e2ff 100644 --- a/src/addons/mod/workshop/services/workshop.ts +++ b/src/addons/mod/workshop/services/workshop.ts @@ -17,7 +17,6 @@ import { CoreError } from '@classes/errors/error'; import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreCourseLogHelper } from '@features/course/services/log-helper'; -import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader'; import { CoreGradesMenuItem } from '@features/grades/services/grades-helper'; import { CoreApp } from '@services/app'; import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; @@ -718,7 +717,7 @@ export class AddonModWorkshopProvider { courseId: number, title: string, content: string, - attachmentsId?: number | CoreFileUploaderStoreFilesResult, + attachmentsId?: number, siteId?: string, allowOffline: boolean = false, ): Promise { @@ -731,7 +730,7 @@ export class AddonModWorkshopProvider { courseId, title, content, - attachmentsId as CoreFileUploaderStoreFilesResult, + undefined, undefined, AddonModWorkshopAction.ADD, siteId, @@ -814,7 +813,7 @@ export class AddonModWorkshopProvider { courseId: number, title: string, content: string, - attachmentsId?: CoreFileUploaderStoreFilesResult | number | undefined, + attachmentsId?: number | undefined, siteId?: string, allowOffline: boolean = false, ): Promise { @@ -827,7 +826,7 @@ export class AddonModWorkshopProvider { courseId, title, content, - attachmentsId as CoreFileUploaderStoreFilesResult, + undefined, submissionId, AddonModWorkshopAction.UPDATE, siteId,