From 9d6706a5b8f11e2214537f4acb1c333efb191469 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 4 Jul 2023 07:30:09 +0200 Subject: [PATCH] debug state updates --- src/app.jsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/app.jsx b/src/app.jsx index 0d6ed51fc..22537a3d6 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -33,6 +33,7 @@ import ContainerHeader from './ContainerHeader.jsx'; import Containers from './Containers.jsx'; import Images from './Images.jsx'; import * as client from './client.js'; +import { debug } from './util.js'; const _ = cockpit.gettext; @@ -155,12 +156,8 @@ class Application extends React.Component { updateState(state, id, newValue) { this.setState(prevState => { - const copyState = Object.assign({}, prevState[state]); - - copyState[id] = newValue; - return { - [state]: copyState, + [state]: { ...prevState[state], [id]: newValue } }; }); } @@ -211,6 +208,7 @@ class Application extends React.Component { ) )) .then(reply => { + debug(system, "updateContainersAfterEvent init", init, "getContainers", JSON.stringify(reply)); this.setState(prevState => { // Copy only containers that could not be deleted with this event // So when event from system come, only copy user containers and vice versa @@ -314,6 +312,7 @@ class Application extends React.Component { // override it to reconnect console after restart if (event && event.Action === "restart") reply.State = "restarting"; + debug(system, "updateContainerAfterEvent", id, "event", event?.Action, "new state:", JSON.stringify(reply)); this.updateState("containers", reply.Id + system.toString(), reply); if (["running", "created", "exited", "paused", "stopped"].find(containerState => containerState === reply.State)) { this.inspectContainerDetail(reply.Id, system);