MOBILE-3320 workshop: Fix filesObject.online.length error

main
Dani Palou 2021-06-11 16:23:40 +02:00
parent 65f18cc670
commit 0075a3880f
3 changed files with 14 additions and 13 deletions

View File

@ -802,14 +802,14 @@ export class AddonModDataHelperProvider {
offline: boolean, offline: boolean,
siteId?: string, siteId?: string,
): Promise<number | CoreFileUploaderStoreFilesResult> { ): Promise<number | CoreFileUploaderStoreFilesResult> {
if (!files.length) {
return 0;
}
if (offline) { if (offline) {
return this.storeFiles(dataId, entryId, fieldId, files, siteId); return this.storeFiles(dataId, entryId, fieldId, files, siteId);
} }
if (!files.length) {
return 0;
}
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModDataProvider.COMPONENT, itemId, siteId); return CoreFileUploader.uploadOrReuploadFiles(files, AddonModDataProvider.COMPONENT, itemId, siteId);
} }

View File

@ -332,7 +332,9 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
// Upload attachments first if any. // Upload attachments first if any.
let allowOffline = !inputData.attachmentfiles.length; let allowOffline = !inputData.attachmentfiles.length;
try { try {
let attachmentsId: CoreFileUploaderStoreFilesResult | number | undefined; let attachmentsId: number | undefined;
let storeFilesResult: CoreFileUploaderStoreFilesResult | undefined;
try { try {
attachmentsId = await AddonModWorkshopHelper.uploadOrStoreSubmissionFiles( attachmentsId = await AddonModWorkshopHelper.uploadOrStoreSubmissionFiles(
this.workshopId, this.workshopId,
@ -344,7 +346,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
saveOffline = true; saveOffline = true;
allowOffline = true; allowOffline = true;
attachmentsId = await AddonModWorkshopHelper.uploadOrStoreSubmissionFiles( storeFilesResult = await AddonModWorkshopHelper.uploadOrStoreSubmissionFiles(
this.workshopId, this.workshopId,
inputData.attachmentfiles, inputData.attachmentfiles,
true, true,
@ -364,7 +366,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
this.courseId, this.courseId,
inputData.title, inputData.title,
inputData.content, inputData.content,
attachmentsId as CoreFileUploaderStoreFilesResult, storeFilesResult,
submissionId, submissionId,
AddonModWorkshopAction.UPDATE, AddonModWorkshopAction.UPDATE,
); );
@ -391,7 +393,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
this.courseId, this.courseId,
inputData.title, inputData.title,
inputData.content, inputData.content,
attachmentsId as CoreFileUploaderStoreFilesResult, storeFilesResult,
undefined, undefined,
AddonModWorkshopAction.ADD, AddonModWorkshopAction.ADD,
); );

View File

@ -17,7 +17,6 @@ import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper'; import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { CoreGradesMenuItem } from '@features/grades/services/grades-helper'; import { CoreGradesMenuItem } from '@features/grades/services/grades-helper';
import { CoreApp } from '@services/app'; import { CoreApp } from '@services/app';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
@ -718,7 +717,7 @@ export class AddonModWorkshopProvider {
courseId: number, courseId: number,
title: string, title: string,
content: string, content: string,
attachmentsId?: number | CoreFileUploaderStoreFilesResult, attachmentsId?: number,
siteId?: string, siteId?: string,
allowOffline: boolean = false, allowOffline: boolean = false,
): Promise<number | false> { ): Promise<number | false> {
@ -731,7 +730,7 @@ export class AddonModWorkshopProvider {
courseId, courseId,
title, title,
content, content,
attachmentsId as CoreFileUploaderStoreFilesResult, undefined,
undefined, undefined,
AddonModWorkshopAction.ADD, AddonModWorkshopAction.ADD,
siteId, siteId,
@ -814,7 +813,7 @@ export class AddonModWorkshopProvider {
courseId: number, courseId: number,
title: string, title: string,
content: string, content: string,
attachmentsId?: CoreFileUploaderStoreFilesResult | number | undefined, attachmentsId?: number | undefined,
siteId?: string, siteId?: string,
allowOffline: boolean = false, allowOffline: boolean = false,
): Promise<number | false> { ): Promise<number | false> {
@ -827,7 +826,7 @@ export class AddonModWorkshopProvider {
courseId, courseId,
title, title,
content, content,
attachmentsId as CoreFileUploaderStoreFilesResult, undefined,
submissionId, submissionId,
AddonModWorkshopAction.UPDATE, AddonModWorkshopAction.UPDATE,
siteId, siteId,