Skip to content

Commit

Permalink
chore: rebase on updated master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Extheoisah committed Apr 3, 2024
1 parent 1b157e9 commit d091e7d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/store/models/network.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { remote, SaveDialogOptions } from 'electron';
import { ipcRenderer, remote, SaveDialogOptions } from 'electron';
import { info } from 'electron-log';
import { join } from 'path';
import { push } from 'connected-react-router';
Expand Down Expand Up @@ -766,6 +766,26 @@ const networkModel: NetworkModel = {
}
},
),
stopAll: thunk(async (actions, _, { getState }) => {
let networks = getState().networks.filter(
n => n.status === Status.Started || n.status === Status.Stopping,
);
if (networks.length === 0) {
ipcRenderer.send('docker-shut-down');
}
networks.forEach(async network => {
await actions.stop(network.id);
});
setInterval(async () => {
networks = getState().networks.filter(
n => n.status === Status.Started || n.status === Status.Stopping,
);
if (networks.length === 0) {
await actions.save();
ipcRenderer.send('docker-shut-down');
}
}, 2000);
}),
toggle: thunk(async (actions, networkId, { getState }) => {
const network = getState().networks.find(n => n.id === networkId);
if (!network) throw new Error(l('networkByIdErr', { networkId }));
Expand Down

0 comments on commit d091e7d

Please sign in to comment.