Skip to content

Commit

Permalink
fix(instance) avoid races on start/stopping of instances
Browse files Browse the repository at this point in the history
Signed-off-by: David Edler <[email protected]>
  • Loading branch information
edlerd committed Feb 13, 2024
1 parent a60565c commit 27196ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/context/instanceLoading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ export const InstanceLoadingProvider: FC<Props> = ({ children }) => {
);

const setLoading = (instance: LxdInstance, loadingType: LoadingTypes) => {
const newMap = new Map(instanceStates);
newMap.set(instance.name, loadingType);
setInstanceStates(newMap);
setInstanceStates((oldMap) => {
const newMap = new Map(oldMap);
newMap.set(instance.name, loadingType);
return newMap;
});
};

const setFinish = (instance: LxdInstance) => {
const newMap = new Map(instanceStates);
newMap.delete(instance.name);
setInstanceStates(newMap);
setInstanceStates((oldMap) => {
const newMap = new Map(oldMap);
newMap.delete(instance.name);
return newMap;
});
};

return (
Expand Down
1 change: 0 additions & 1 deletion src/pages/networks/NetworkForwards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ const NetworkForwards: FC<Props> = ({ network, project }) => {
expanding
rows={rows}
paginate={30}
responsive
sortable
defaultSort="listenAddress"
defaultSortDirection="ascending"
Expand Down

0 comments on commit 27196ec

Please sign in to comment.