1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

ensure old, saved port-forwards get loaded (#4668)

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
Jim Ehrismann 2022-01-11 09:35:55 -05:00 committed by GitHub
parent f7f27a8304
commit 58ffb8e3e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,14 +47,14 @@ export class PortForwardStore extends ItemStore<PortForwardItem> {
const savedPortForwards = this.storage.get(); // undefined on first load
if (Array.isArray(savedPortForwards)) {
if (Array.isArray(savedPortForwards) && savedPortForwards.length > 0) {
logger.info("[PORT-FORWARD-STORE] starting saved port-forwards");
// add the disabled ones
await Promise.all(savedPortForwards.filter(pf => pf.status === "Disabled").map(addPortForward));
// add the active ones and check if they started successfully
const results = await Promise.allSettled(savedPortForwards.filter(pf => pf.status === "Active").map(addPortForward));
// add the active ones (assume active if the status is undefined, for backward compatibilty) and check if they started successfully
const results = await Promise.allSettled(savedPortForwards.filter(pf => !pf.status || pf.status === "Active").map(addPortForward));
for (const result of results) {
if (result.status === "rejected" || result.value.status === "Disabled") {