From d091e7d5d71e94ce9ad86a801b948eb833e5536a Mon Sep 17 00:00:00 2001 From: Theophilus Date: Wed, 3 Apr 2024 23:43:44 +0100 Subject: [PATCH] chore: rebase on updated master branch --- src/store/models/network.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/store/models/network.ts b/src/store/models/network.ts index 754028c672..9311f50a46 100644 --- a/src/store/models/network.ts +++ b/src/store/models/network.ts @@ -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'; @@ -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 }));