diff --git a/src/app.jsx b/src/app.jsx index 669055358..ef203047a 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -190,7 +190,7 @@ class Application extends React.Component { .then(scriptResult => scriptResult === "0\n"); } - updateContainers(system, init) { + initContainers(system) { return client.getContainers(system) .then(reply => Promise.all( (reply || []).map(container => @@ -203,7 +203,7 @@ class Application extends React.Component { ) )) .then(reply => { - debug(system, "updateContainers init", init, "getContainers", JSON.stringify(reply)); + debug(system, "initContainers 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 @@ -222,11 +222,9 @@ class Application extends React.Component { [system ? "systemContainersLoaded" : "userContainersLoaded"]: true, }; }); - if (init) { - this.updateContainerStats(system); - for (const container of reply || []) { - this.inspectContainerDetail(container.Id, system); - } + this.updateContainerStats(system); + for (const container of reply || []) { + this.inspectContainerDetail(container.Id, system); } }) .catch(console.log); @@ -412,13 +410,10 @@ class Application extends React.Component { this.updateContainer(event.Actor.ID, system, event); break; case 'remove': - this.updateContainers(system).then(() => { - // HACK: we don't get a pod event when a container in a pod is removed. - // https://github.com/containers/podman/issues/15408 - if (event.Actor.Attributes.podId) - this.updatePod(event.Actor.Attributes.podId, system); - else - this.updatePods(system); + this.setState(prevState => { + const containers = { ...prevState.containers }; + delete containers[event.id + system.toString()]; + return { containers }; }); break; /* The following events need only to update the Image list */ @@ -488,7 +483,7 @@ class Application extends React.Component { cgroupVersion: reply.host.cgroupVersion, }); this.updateImages(system); - this.updateContainers(system, true); + this.initContainers(system); this.updatePods(system); client.streamEvents(system, message => this.handleEvent(message, system))