I currently have a progress bar that changes when a user deletes a file. The model changes, and the progress bar only changes once I refresh the page. How do I get the progress bar to update without refreshing? Here is the child deleteFile method.
public async deleteFile(item: any) {
this.openDialogDeletePrompt().subscribe(async confirmation => {
if (confirmation === true) {
if(item.id === 0){
//Keep all files that are not id 0
this.target.resultAttachments = [...this.target.resultAttachments ?? []].filter(i => i.id !== item.id);
//Updated target resultAttachments, but keep all other properities the same
this.target = {
...this.target,
resultAttachments: this.target.resultAttachments,
}
}
else{
let deleteFileResponse = await this._monitoringService.deleteFile(item.id)
if (deleteFileResponse) {
this.target.resultAttachments = [...this.target.resultAttachments ?? []].filter(i => i.id !== item.id);
this.target = {
...this.target,
resultAttachments: this.target.resultAttachments,
status: deleteFileResponse.targetStatus !== undefined ? deleteFileResponse.targetStatus : this.target.status
};
this.task.status = deleteFileResponse.taskStatus !== undefined ? deleteFileResponse.taskStatus : this.task.status;
this.task.taskType = deleteFileResponse.taskType;
this.targetChange.emit(this.target);
}
}
}
this.cd.detectChanges();
})
}