Skip to content

Commit

Permalink
fix change view fast bug (#6706)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael18811380328 authored Sep 4, 2024
1 parent 6f9d82d commit a13dc82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions frontend/src/metadata/metadata-view/components/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,26 @@ const View = () => {
const { isLoading, metadata, errorMsg } = useMetadata();

const renderView = useCallback((metadata) => {
if (!metadata) return false;
const viewType = metadata.view.type;
if (viewType === VIEW_TYPE.GALLERY) return (<Gallery />);
return (<Table />);
switch (viewType) {
case VIEW_TYPE.GALLERY: {
return <Gallery />;
}
case VIEW_TYPE.TABLE: {
return <Table />;
}
default:
return null;
}
}, []);

if (isLoading) return (<CenteredLoading />);

return (
<div className="sf-metadata-wrapper">
<div className="sf-metadata-main">
{errorMsg && (<div className="d-center-middle error">{gettext(errorMsg)}</div>)}
{!errorMsg && renderView(metadata)}
{errorMsg ? <div className="d-center-middle error">{gettext(errorMsg)}</div> : renderView(metadata)}
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/metadata/metadata-view/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Context {
// metadata
getMetadata = (params) => {
const repoID = this.settings['repoID'];
return this.metadataAPI.getMetadata(repoID, params);
return this.metadataAPI ? this.metadataAPI.getMetadata(repoID, params) : null;
};

getRecord = (parentDir, fileName) => {
Expand Down

0 comments on commit a13dc82

Please sign in to comment.