diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts index 1f5ad6b7fc..00b2c19405 100644 --- a/web/packages/gallery/components/viewer/photoswipe.ts +++ b/web/packages/gallery/components/viewer/photoswipe.ts @@ -639,10 +639,11 @@ export class FileViewerPhotoSwipe { button.disabled = pendingFavoriteUpdates.has(af.file.id); // Update the fill visibility based on the favorite status. - showIf( - document.getElementById("pswp__icn-favorite-fill")!, - !!delegate.isFavorite(af), - ); + const fill = document.getElementById("pswp__icn-favorite-fill"); + if (fill) { + // Need a null check since we might've been closed meanwhile. + showIf(fill, !!delegate.isFavorite(af)); + } }; const handleToggleFavorite = () => void toggleFavorite();