Ensure allocations are persisted across page navigation correctly; closes #2729

This commit is contained in:
Dane Everitt 2021-04-20 20:48:40 -07:00
parent d2955b9361
commit 38a5f2dbbf
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -11,6 +11,7 @@ import Can from '@/components/elements/Can';
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
import getServerAllocations from '@/api/swr/getServerAllocations';
import isEqual from 'react-fast-compare';
import { useDeepCompareEffect } from '@/plugins/useDeepCompareEffect';
const NetworkContainer = () => {
const [ loading, setLoading ] = useState(false);
@ -23,7 +24,7 @@ const NetworkContainer = () => {
const { data, error, mutate } = getServerAllocations();
useEffect(() => {
mutate(allocations, false);
mutate(allocations);
}, []);
useEffect(() => {
@ -32,6 +33,12 @@ const NetworkContainer = () => {
}
}, [ error ]);
useDeepCompareEffect(() => {
if (!data) return;
setServerFromState(state => ({ ...state, allocations: data }));
}, [ data ]);
const onCreateAllocation = () => {
clearFlashes('server:network');