Skip to content

Commit

Permalink
fix(ui): Automatically refresh the updater state
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypfer committed Dec 5, 2021
1 parent f019064 commit 596dc06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
5 changes: 4 additions & 1 deletion frontend/src/api/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,10 @@ export const useCombinedVirtualRestrictionsMutation = (
};

export const useUpdaterStateQuery = () => {
return useQuery(CacheKey.UpdaterState, fetchUpdaterState);
return useQuery(CacheKey.UpdaterState, fetchUpdaterState, {
staleTime: 5_000,
refetchInterval: 5_000
});
};

export const useUpdaterCommandMutation = () => {
Expand Down
16 changes: 0 additions & 16 deletions frontend/src/settings/Updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,6 @@ const StartUpdateControls: FunctionComponent = () => {
const [dialogOpen, setDialogOpen] = React.useState(false);
const {mutate: sendCommand, isLoading: commandExecuting} = useUpdaterCommandMutation();

const {
refetch: refetchUpdaterState,
} = useUpdaterStateQuery();


return (
<>
<LoadingButton loading={commandExecuting} variant="outlined" onClick={() => {
Expand All @@ -253,9 +248,6 @@ const StartUpdateControls: FunctionComponent = () => {
setDialogOpen(false);
}} onAccept={() => {
sendCommand("check");
setTimeout(() => {
refetchUpdaterState().then();
}, 2000); //TODO: this could be better
}}/>
</>
);
Expand All @@ -265,11 +257,6 @@ const DownloadUpdateControls: FunctionComponent = () => {
const [dialogOpen, setDialogOpen] = React.useState(false);
const {mutate: sendCommand, isLoading: commandExecuting} = useUpdaterCommandMutation();

const {
refetch: refetchUpdaterState,
} = useUpdaterStateQuery();


return (
<>
<LoadingButton loading={commandExecuting} variant="outlined" onClick={() => {
Expand All @@ -281,9 +268,6 @@ const DownloadUpdateControls: FunctionComponent = () => {
setDialogOpen(false);
}} onAccept={() => {
sendCommand("download");
setTimeout(() => {
refetchUpdaterState().then();
}, 100); //TODO: this could be better
}}/>
</>
);
Expand Down

0 comments on commit 596dc06

Please sign in to comment.