mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-20 07:13:45 +02:00
Fix server state not being updated correctly when adding/removing allocation; closes #2680
This commit is contained in:
@@ -13,8 +13,11 @@ interface Props {
|
||||
}
|
||||
|
||||
const DeleteAllocationButton = ({ allocation }: Props) => {
|
||||
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
||||
const [ confirm, setConfirm ] = useState(false);
|
||||
|
||||
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
||||
const setServerFromState = ServerContext.useStoreActions(actions => actions.server.setServerFromState);
|
||||
|
||||
const { mutate } = getServerAllocations();
|
||||
const { clearFlashes, clearAndAddHttpError } = useFlash();
|
||||
|
||||
@@ -22,6 +25,8 @@ const DeleteAllocationButton = ({ allocation }: Props) => {
|
||||
clearFlashes('server:network');
|
||||
|
||||
mutate(data => data?.filter(a => a.id !== allocation), false);
|
||||
setServerFromState(s => ({ ...s, allocations: s.allocations.filter(a => a.id !== allocation) }));
|
||||
|
||||
deleteServerAllocation(uuid, allocation)
|
||||
.catch(error => clearAndAddHttpError({ key: 'server:network', error }));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user