mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 22:45:45 +01:00
Fix review findings
This commit is contained in:
@@ -37,32 +37,25 @@ const SourcecodeViewer: FC<Props> = ({ file, language }) => {
|
||||
const [currentFileRevision, setCurrentFileRevision] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
function fetchContent() {
|
||||
if (file.revision !== currentFileRevision) {
|
||||
getContent((file._links.self as Link).href)
|
||||
.then(content => {
|
||||
setLoading(false);
|
||||
setContent(content);
|
||||
setCurrentFileRevision(file.revision);
|
||||
})
|
||||
.catch(error => {
|
||||
setLoading(false);
|
||||
setError(error);
|
||||
});
|
||||
})
|
||||
.catch(setError);
|
||||
}
|
||||
|
||||
if (file.revision !== currentFileRevision) {
|
||||
fetchContent();
|
||||
}
|
||||
});
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
}, [currentFileRevision, file]);
|
||||
|
||||
if (error) {
|
||||
return <ErrorNotification error={error} />;
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user