Skip to content

Commit 38a5f2d

Browse files
committed
Ensure allocations are persisted across page navigation correctly; closes pterodactyl#2729
1 parent d2955b9 commit 38a5f2d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

resources/scripts/components/server/network/NetworkContainer.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Can from '@/components/elements/Can';
1111
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
1212
import getServerAllocations from '@/api/swr/getServerAllocations';
1313
import isEqual from 'react-fast-compare';
14+
import { useDeepCompareEffect } from '@/plugins/useDeepCompareEffect';
1415

1516
const NetworkContainer = () => {
1617
const [ loading, setLoading ] = useState(false);
@@ -23,7 +24,7 @@ const NetworkContainer = () => {
2324
const { data, error, mutate } = getServerAllocations();
2425

2526
useEffect(() => {
26-
mutate(allocations, false);
27+
mutate(allocations);
2728
}, []);
2829

2930
useEffect(() => {
@@ -32,6 +33,12 @@ const NetworkContainer = () => {
3233
}
3334
}, [ error ]);
3435

36+
useDeepCompareEffect(() => {
37+
if (!data) return;
38+
39+
setServerFromState(state => ({ ...state, allocations: data }));
40+
}, [ data ]);
41+
3542
const onCreateAllocation = () => {
3643
clearFlashes('server:network');
3744

0 commit comments

Comments
 (0)