Skip to content

Commit

Permalink
debug state updates
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpitt committed Jul 5, 2023
1 parent 2118fbd commit 5a28f0d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 }
};
});
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5a28f0d

Please sign in to comment.