Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix npe

Manav Rathi7fc03a71e7f0
diff --git a/web/packages/gallery/components/FileInfo.tsx b/web/packages/gallery/components/FileInfo.tsx
index 7be8d32ea3..ec49c17b17 100644
--- a/web/packages/gallery/components/FileInfo.tsx
+++ b/web/packages/gallery/components/FileInfo.tsx
@@ -7,6 +7,7 @@ Plan of action:
and photos/FileInfo to deal with the @/new/photos imports here.
*/
+import { assertionFailed } from "@/base/assert";
import { LinkButtonUndecorated } from "@/base/components/LinkButton";
import { type ButtonishProps } from "@/base/components/mui";
import { ActivityIndicator } from "@/base/components/mui/ActivityIndicator";
@@ -225,6 +226,7 @@ export const FileInfo: React.FC<FileInfoProps> = ({
onSelectPerson?.(personID);
if (!file) {
+ if (open) assertionFailed();
return <></>;
}
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index 4c21d1dab3..0f536fe25a 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -189,7 +189,7 @@ const FileViewer: React.FC<FileViewerProps> = ({
<Button>Test</Button>
<FileInfo
{...fileInfoVisibilityProps}
- file={activeAnnotatedFile.file}
+ file={activeAnnotatedFile?.file}
exif={activeFileExif}
onSelectCollection={handleSelectCollection}
onSelectPerson={handleSelectPerson}
diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts
index b1d9053f60..0c67c70521 100644
--- a/web/packages/gallery/components/viewer/photoswipe.ts
+++ b/web/packages/gallery/components/viewer/photoswipe.ts
@@ -221,7 +221,7 @@ export class FileViewerPhotoSwipe {
// The above condition implies that annotation can never be
// undefined, but it doesn't seem to be enough to convince
// TypeScript. Writing the condition in a more unnatural way
- // `(annotation && annotation?.fileID == file.id)` works, but
+ // `(!(annotation && annotation?.fileID == file.id))` works, but
// instead we use a non-null assertion here.
annotation: annotation!,
};
@@ -231,7 +231,7 @@ export class FileViewerPhotoSwipe {
const withCurrentAnnotatedFile =
(cb: (af: AnnotatedFile) => void) => () =>
- cb(currentFileAnnotation());
+ cb(currentAnnotatedFile());
// Provide data about slides to PhotoSwipe via callbacks
// https://photoswipe.com/data-sources/#dynamically-generated-data