Fixed bug in file deletion

This commit is contained in:
Isaac Abadi
2020-12-19 01:46:19 -05:00
parent 9847577431
commit 59c38321fd
2 changed files with 8 additions and 5 deletions

View File

@@ -127,9 +127,11 @@ export class RecentVideosComponent implements OnInit {
this.normal_files_received = false;
this.postsService.getAllFiles().subscribe(res => {
this.files = res['files'];
this.files.forEach(file => {
for (let i = 0; i < this.files.length; i++) {
const file = this.files[i];
file.duration = typeof file.duration !== 'string' ? file.duration : this.durationStringToNumber(file.duration);
});
file.index = i;
}
this.files.sort(this.sortFiles);
if (this.search_mode) {
this.filterFiles(this.search_text);
@@ -247,7 +249,8 @@ export class RecentVideosComponent implements OnInit {
this.postsService.deleteFile(file.uid, file.isAudio ? 'audio' : 'video', blacklistMode).subscribe(result => {
if (result) {
this.postsService.openSnackBar('Delete success!', 'OK.');
this.files.splice(index, 1);
this.files.splice(file.index, 1);
this.filterByProperty(this.filterProperty['property']);
} else {
this.postsService.openSnackBar('Delete failed!', 'OK.');
}