activated typescript strict mode
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user