From dd49706885c8221424e737e04519377b4b101fbb Mon Sep 17 00:00:00 2001 From: ~latter-bolden Date: Thu, 2 Jun 2022 04:03:15 -0400 Subject: [PATCH] prevent stale ship statuses by checking running piers on startup --- src/background/services/pier-service.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/background/services/pier-service.ts b/src/background/services/pier-service.ts index 4fd56a9..7430a6e 100644 --- a/src/background/services/pier-service.ts +++ b/src/background/services/pier-service.ts @@ -99,6 +99,7 @@ export class PierService { async start(): Promise { await this.setPierDirectory(); await this.migrate(); + await this.checkRunningShips(); await this.recoverShips(); await this.getPiers().then(piers => { ipcRenderer.invoke('piers', piers); @@ -134,6 +135,14 @@ export class PierService { console.log('pier service migrated successfully'); } } + + async checkRunningShips(): Promise { + let piers = await this.getPiers(); + let runningPiers = piers.filter(pier => pier.status === 'running'); + await each(runningPiers, async (pier) => { + await this.checkPier(pier); + }); + } async setPierDirectory(): Promise { const pierDirectory = await this.db.settings.asyncFindOne({ name: 'pier-directory' })