Merge pull request #3133 from dpalou/MOBILE-3780
MOBILE-3780 attachments: Fix detect file size in Androidmain
commit
513e669a12
|
@ -0,0 +1,5 @@
|
|||
:host {
|
||||
core-loading {
|
||||
--loading-inline-min-height: 60px;
|
||||
}
|
||||
}
|
|
@ -42,6 +42,7 @@ import { CoreUtils } from '@services/utils/utils';
|
|||
@Component({
|
||||
selector: 'core-attachments',
|
||||
templateUrl: 'core-attachments.html',
|
||||
styleUrls: ['attachments.scss'],
|
||||
})
|
||||
export class CoreAttachmentsComponent implements OnInit {
|
||||
|
||||
|
@ -59,16 +60,17 @@ export class CoreAttachmentsComponent implements OnInit {
|
|||
maxSubmissionsReadable?: string;
|
||||
unlimitedFiles?: boolean;
|
||||
fileTypes?: CoreFileUploaderTypeList;
|
||||
loaded = false;
|
||||
|
||||
/**
|
||||
* Component being initialized.
|
||||
* @inheritdoc
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
async ngOnInit(): Promise<void> {
|
||||
this.files = this.files || [];
|
||||
this.maxSize = this.maxSize !== null ? Number(this.maxSize) : NaN;
|
||||
|
||||
if (this.maxSize === 0) {
|
||||
this.getMaxSizeOfArea();
|
||||
await this.getMaxSizeOfArea();
|
||||
} else if (this.maxSize > 0) {
|
||||
this.maxSizeReadable = CoreTextUtils.bytesToSize(this.maxSize, 2);
|
||||
} else if (this.maxSize === -1) {
|
||||
|
@ -90,6 +92,8 @@ export class CoreAttachmentsComponent implements OnInit {
|
|||
if (this.acceptedTypes && this.acceptedTypes != '*') {
|
||||
this.fileTypes = CoreFileUploader.prepareFiletypeList(this.acceptedTypes);
|
||||
}
|
||||
|
||||
this.loaded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<core-loading [hideUntil]="loaded" [fullscreen]="false">
|
||||
<ion-item class="ion-text-wrap">
|
||||
<ion-label>
|
||||
<span *ngIf="maxSubmissionsReadable">
|
||||
|
@ -24,7 +25,8 @@
|
|||
</core-file>
|
||||
|
||||
<!-- Files added to draft but not attached to submission yet. -->
|
||||
<core-local-file *ngIf="file.name" [file]="file" [manage]="true" (onDelete)="delete(index, false)" (onRename)="renamed(index, $event)">
|
||||
<core-local-file *ngIf="file.name" [file]="file" [manage]="true" (onDelete)="delete(index, false)"
|
||||
(onRename)="renamed(index, $event)">
|
||||
</core-local-file>
|
||||
</div>
|
||||
|
||||
|
@ -35,3 +37,4 @@
|
|||
<ion-icon name="fas-plus" slot="start" aria-hidden="true"></ion-icon>
|
||||
{{ 'core.fileuploader.addfiletext' | translate }}
|
||||
</ion-button>
|
||||
</core-loading>
|
||||
|
|
|
@ -204,7 +204,6 @@ export class CoreFileUploaderHelperProvider {
|
|||
|
||||
// Check that size isn't too large.
|
||||
if (maxSize !== undefined && maxSize != -1) {
|
||||
try {
|
||||
const fileEntry = await CoreFile.getExternalFile(path);
|
||||
|
||||
const fileData = await CoreFile.getFileObjectFromFileEntry(fileEntry);
|
||||
|
@ -212,9 +211,6 @@ export class CoreFileUploaderHelperProvider {
|
|||
if (fileData.size > maxSize) {
|
||||
throw this.createMaxBytesError(maxSize, fileEntry.name);
|
||||
}
|
||||
} catch (error) {
|
||||
// Ignore failures.
|
||||
}
|
||||
}
|
||||
|
||||
// File isn't too large.
|
||||
|
|
Loading…
Reference in New Issue