Ensure allocations are persisted across page navigation correctly; closes #2729
This commit is contained in:
parent
d2955b9361
commit
38a5f2dbbf
1 changed files with 8 additions and 1 deletions
|
@ -11,6 +11,7 @@ import Can from '@/components/elements/Can';
|
||||||
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
||||||
import getServerAllocations from '@/api/swr/getServerAllocations';
|
import getServerAllocations from '@/api/swr/getServerAllocations';
|
||||||
import isEqual from 'react-fast-compare';
|
import isEqual from 'react-fast-compare';
|
||||||
|
import { useDeepCompareEffect } from '@/plugins/useDeepCompareEffect';
|
||||||
|
|
||||||
const NetworkContainer = () => {
|
const NetworkContainer = () => {
|
||||||
const [ loading, setLoading ] = useState(false);
|
const [ loading, setLoading ] = useState(false);
|
||||||
|
@ -23,7 +24,7 @@ const NetworkContainer = () => {
|
||||||
const { data, error, mutate } = getServerAllocations();
|
const { data, error, mutate } = getServerAllocations();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
mutate(allocations, false);
|
mutate(allocations);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -32,6 +33,12 @@ const NetworkContainer = () => {
|
||||||
}
|
}
|
||||||
}, [ error ]);
|
}, [ error ]);
|
||||||
|
|
||||||
|
useDeepCompareEffect(() => {
|
||||||
|
if (!data) return;
|
||||||
|
|
||||||
|
setServerFromState(state => ({ ...state, allocations: data }));
|
||||||
|
}, [ data ]);
|
||||||
|
|
||||||
const onCreateAllocation = () => {
|
const onCreateAllocation = () => {
|
||||||
clearFlashes('server:network');
|
clearFlashes('server:network');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue