When performing activities like upload, download, delete, and edit, I display statuses such as 'upload started' or 'upload completed'. This works perfectly when staying on the same page. However, there are instances where a user may navigate to a different page after clicking on the download button. In such cases, although the download API is successfully executed, the status remains stuck at 'download in progress'. Is there a way to handle this scenario differently?
download(){
let object = {
message: '',
subactivity: []
};
this.elements.foreach(e => {
object.message = 'download in progress';
object.subactivity.unshift({
id: e.id,
status: 'preparing',
message: 'download inprogress',
})
this.activity.unshift(object);
await downloadElements(element);
});
async downloadElements(element){
...
let result = await this.service.download(this.role,element).pipe(first()).toPromise();
if (result) {
var arr2 = [{
id: element.id,
status: 'success',
message: 'download complete'
}];
var res = this.activity[0].subactivity.findIndex(obj => {
return obj.id === arr2[0].id;
});
this.activity[0].subactivity[res] = arr2[0];
}
const blob = new Blob(result, { type: contentType });
saveAs(blob, fileName);