Skip to content

Commit

Permalink
Another inmutability fix
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Sep 4, 2024
1 parent a705ac6 commit d0bf495
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions web/src/queries/dasd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import {
import { useInstallerClient } from "~/context/installer";
import React from "react";
import { hex } from "~/utils";
import { DASDDevice, FilterDASD, FormatJob } from "~/types/dasd";
import { fetchStorageJobs, findStorageJob } from "~/api/storage";
import { DASDDevice, FormatJob } from "~/types/dasd";
import { fetchStorageJobs } from "~/api/storage";

/**
* Returns a query for retrieving the dasd devices
Expand Down Expand Up @@ -100,9 +100,8 @@ const useDASDFormatJobChanges = () => {
case "JobAdded": {
const formatJob: FormatJob = { jobId: event.job.id };
const data = queryClient.getQueryData(["dasd", "formatJobs", "running"]) as FormatJob[];
data.push(formatJob);

queryClient.setQueryData(["dasd", "formatJobs", "running"], data);
queryClient.setQueryData(["dasd", "formatJobs", "running"], [...data, formatJob]);
break;
}
case "JobChanged": {
Expand Down Expand Up @@ -138,9 +137,7 @@ const useDASDDevicesChanges = () => {
case "DASDDeviceAdded": {
const device: DASDDevice = event.device;
queryClient.setQueryData(["dasd", "devices"], (prev: DASDDevice[]) => {
// do not use push here as updater has to be immutable
const res = prev.concat([device]);
return res;
return [...prev, device];
});
break;
}
Expand Down

0 comments on commit d0bf495

Please sign in to comment.