activated typescript strict mode

This commit is contained in:
2021-05-22 15:30:04 +02:00
parent a195fafa6b
commit cb2c028ca4
76 changed files with 511 additions and 296 deletions

View File

@@ -13,18 +13,28 @@ import {File} from '../../../services/file';
styleUrls: ['./edit-file.component.less'],
})
export class EditFileComponent {
public selectedFiles: FileList;
public currentUpload: Upload;
public songId: string;
public selectedFiles: FileList | null = null;
public currentUpload: Upload | null = null;
public songId: string | null = null;
public files$: Observable<File[]>;
public constructor(private activatedRoute: ActivatedRoute, private uploadService: UploadService, private fileService: FileDataService) {
this.activatedRoute.params.pipe(map((param: {songId: string}) => param.songId)).subscribe(songId => {
this.songId = songId;
});
public constructor(
private activatedRoute: ActivatedRoute,
private uploadService: UploadService,
private fileService: FileDataService
) {
this.activatedRoute.params
.pipe(
map(param => param as {songId: string}),
map(param => param.songId)
)
.subscribe(songId => {
this.songId = songId;
});
this.files$ = this.activatedRoute.params.pipe(
map((param: {songId: string}) => param.songId),
map(param => param as {songId: string}),
map(param => param.songId),
switchMap(songId => this.fileService.read$(songId))
);
}
@@ -35,7 +45,9 @@ export class EditFileComponent {
}
public uploadSingle(): void {
if (!this.selectedFiles || !this.songId) return;
const file = this.selectedFiles.item(0);
if (!file) return;
this.currentUpload = new Upload(file);
this.uploadService.pushUpload(this.songId, this.currentUpload);
}

View File

@@ -10,12 +10,12 @@ import {FileService} from '../../../../services/file.service';
styleUrls: ['./file.component.less'],
})
export class FileComponent {
public url$: Observable<string>;
public name: string;
public url$: Observable<string> | null = null;
public name = '';
public faTrash = faTrashAlt;
@Input() public songId: string;
private fileId: string;
private path: string;
@Input() public songId: string | null = null;
private fileId: string | null = null;
private path: string | null = null;
public constructor(private fileService: FileService) {}
@@ -28,6 +28,6 @@ export class FileComponent {
}
public async onDelete(): Promise<void> {
await this.fileService.delete(this.path, this.songId, this.fileId);
if (this.path && this.songId && this.fileId) await this.fileService.delete(this.path, this.songId, this.fileId);
}
}