diff --git a/backend/app.js b/backend/app.js index 6476136a..d3f9d57a 100644 --- a/backend/app.js +++ b/backend/app.js @@ -2570,7 +2570,7 @@ app.post('/api/deleteFile', optionalJwt, async (req, res) => { var blacklistMode = req.body.blacklistMode; if (req.isAuthenticated()) { - let success = auth_api.deleteUserFile(req.user.uid, uid, blacklistMode); + let success = await auth_api.deleteUserFile(req.user.uid, uid, blacklistMode); res.send(success); return; } @@ -2583,7 +2583,7 @@ app.post('/api/deleteFile', optionalJwt, async (req, res) => { { wasDeleted = type === 'audio' ? await deleteAudioFile(name, path.basename(fullpath), blacklistMode) : await deleteVideoFile(name, path.basename(fullpath), blacklistMode); db.get('files').remove({uid: uid}).write(); - // wasDeleted = true; + wasDeleted = true; res.send(wasDeleted); } else if (video_obj) { db.get('files').remove({uid: uid}).write(); diff --git a/src/app/components/recent-videos/recent-videos.component.ts b/src/app/components/recent-videos/recent-videos.component.ts index a0667c79..e745138f 100644 --- a/src/app/components/recent-videos/recent-videos.component.ts +++ b/src/app/components/recent-videos/recent-videos.component.ts @@ -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.'); }