Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-WorkGH committed Dec 5, 2023
1 parent 4157d3d commit 7e05ec1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 47 deletions.
30 changes: 0 additions & 30 deletions src/components/TopBar/AboutDialog.d.ts

This file was deleted.

28 changes: 11 additions & 17 deletions src/components/TopBar/AboutDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,39 +73,31 @@ const AboutDialog = ({
getAdditionalComponents,
}) => {
const theme = useTheme();

const [isRefreshing, setRefreshState] = useState(false);

//TODO is useCallback in component or in caller?
const handlerGetGlobalVersion = useCallback(getGlobalVersion, [
getGlobalVersion,
]);
const [loadingGlobalVersion, setLoadingGlobalVersion] = useState(false);

/* We want to get the initial version once at first render to detect later a new deploy */
const [startingGlobalVersion, setStartingGlobalVersion] = useState(null);
const [startingGlobalVersion, setStartingGlobalVersion] =
useState(undefined);
useEffect(() => {
if (getGlobalVersion) {
handlerGetGlobalVersion((value) => {
setLoadingGlobalVersion(false);
if (startingGlobalVersion === undefined && getGlobalVersion) {
getGlobalVersion((value) => {
setStartingGlobalVersion(value);
setActualGlobalVersion(value);
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [getGlobalVersion, startingGlobalVersion]);

const [actualGlobalVersion, setActualGlobalVersion] = useState(null);
useEffect(() => {
if (open && getGlobalVersion) {
setLoadingGlobalVersion(true);
handlerGetGlobalVersion((value) => {
getGlobalVersion((value) => {
setLoadingGlobalVersion(false);
setActualGlobalVersion(value);
setActualGlobalVersion(value || null);
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open, handlerGetGlobalVersion]);
}, [open, getGlobalVersion]);

const [openAdditionalComponents, setOpenAdditionalComponents] =
useState(true);
Expand Down Expand Up @@ -165,7 +157,9 @@ const AboutDialog = ({
<FormattedMessage id={'about-dialog/title'} />
</DialogTitle>
<DialogContent dividers id="alert-dialog-description">
{actualGlobalVersion !== null &&
{startingGlobalVersion !== undefined &&
startingGlobalVersion !== null &&
actualGlobalVersion !== null &&
startingGlobalVersion !== actualGlobalVersion && (
<Collapse in={open}>
<Alert
Expand Down

0 comments on commit 7e05ec1

Please sign in to comment.