Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
prevent stale ship statuses by checking running piers on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
~latter-bolden committed Jun 2, 2022
1 parent 0c2b0dd commit dd49706
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/background/services/pier-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export class PierService {
async start(): Promise<void> {
await this.setPierDirectory();
await this.migrate();
await this.checkRunningShips();
await this.recoverShips();
await this.getPiers().then(piers => {
ipcRenderer.invoke('piers', piers);
Expand Down Expand Up @@ -134,6 +135,14 @@ export class PierService {
console.log('pier service migrated successfully');
}
}

async checkRunningShips(): Promise<void> {
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<void> {
const pierDirectory = await this.db.settings.asyncFindOne({ name: 'pier-directory' })
Expand Down

0 comments on commit dd49706

Please sign in to comment.