Skip to content

Commit

Permalink
fix: ensure blobs are freed on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
macite committed May 11, 2023
1 parent a1e51b6 commit ee017eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/app/common/pdf-viewer/pdf-viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class fPdfViewerComponent implements OnDestroy, OnChanges {
ngOnDestroy(): void {
if (this.pdfBlobUrl) {
this.fileDownloader.releaseBlob(this.pdfBlobUrl);
this.pdfBlobUrl = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, Inject } from '@angular/core';
import { Component, OnInit, Input, Inject, OnDestroy } from '@angular/core';
import { alertService, commentsModal } from 'src/app/ajs-upgraded-providers';
import { Project, TaskComment, Task } from 'src/app/api/models/doubtfire-model';
import { FileDownloaderService } from 'src/app/common/file-downloader/file-downloader';
Expand All @@ -8,7 +8,7 @@ import { FileDownloaderService } from 'src/app/common/file-downloader/file-downl
templateUrl: './pdf-image-comment.component.html',
styleUrls: [],
})
export class PdfImageCommentComponent implements OnInit {
export class PdfImageCommentComponent implements OnInit, OnDestroy {
@Input() comment: TaskComment;
@Input() project: Project;
@Input() task: Task;
Expand All @@ -25,6 +25,13 @@ export class PdfImageCommentComponent implements OnInit {
if (this.comment.commentType === 'image') this.downloadCommentResource();
}

ngOnDestroy(): void {
if (this.resourceUrl) {
this.fileDownloaderService.releaseBlob(this.resourceUrl);
this.resourceUrl = null;
}
}

private downloadCommentResource(fn?: (url: string) => void) {
const url = this.comment.attachmentUrl;

Expand Down

0 comments on commit ee017eb

Please sign in to comment.