Skip to content

Commit

Permalink
fix: properly optional props for FileDisplay
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Jul 15, 2024
1 parent 4372bbf commit 46047ee
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/display/FileDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,13 @@ const WrappedCodeDisplay = ({ contents, fileExt, loading }: WrappedCodeDisplayPr
}
};

type FileDisplay = { uri: string; fileName: string; loading: boolean };
type FileDisplayProps = {
uri?: string;
fileName?: string;
loading?: boolean;
};

const FileDisplay = ({ uri, fileName, loading }: FileDisplay) => {
const FileDisplay = ({ uri, fileName, loading }: FileDisplayProps) => {
const authHeader = useAuthorizationHeader();

const [fileLoadError, setFileLoadError] = useState("");
Expand All @@ -180,7 +184,7 @@ const FileDisplay = ({ uri, fileName, loading }: FileDisplay) => {
setLoadingFileContents(true);
}

if (DEFER_LOADING_FILE_EXTENSIONS.includes(fileExt) || fileContents.hasOwnProperty(uri)) return;
if (DEFER_LOADING_FILE_EXTENSIONS.includes(fileExt) || (uri && fileContents.hasOwnProperty(uri))) return;

if (!uri) {
console.error(`Files: something went wrong while trying to load ${uri}`);
Expand Down

0 comments on commit 46047ee

Please sign in to comment.