Fix npe
This commit is contained in:
@@ -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 <></>;
|
||||
}
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user