From 3cb4f4df51059919b292fefb5f7a3e1ad99c9a91 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 28 Mar 2024 12:11:36 +0100 Subject: [node] stop trying to optimize useless things like local database calls --- nodejs/automation/init.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'nodejs/automation/init.ts') diff --git a/nodejs/automation/init.ts b/nodejs/automation/init.ts index b3c7a40..2850fac 100644 --- a/nodejs/automation/init.ts +++ b/nodejs/automation/init.ts @@ -8,7 +8,8 @@ import { Response } from '../model/api.ts'; import { Contract } from '../model/contract.ts'; import { Ship } from '../model/ship.ts'; import * as api from '../lib/api.ts'; -import * as ships from '../lib/ships.ts'; +import * as libContracts from '../lib/contracts.ts'; +import * as libShips from '../lib/ships.ts'; const symbol = process.env.NODE_ENV === 'test' ? 'ADYXAX-0' : 'ADYXAX-JS'; @@ -27,17 +28,19 @@ export async function init(): Promise { const json = await response.json() as Response<{agent: Agent, contract: Contract, ship: Ship, token: string}>; if (json.error !== undefined) { switch(json.error?.code) { - case 4111: // 4111 means the agent symbol has already been claimed so no server reset happened - return; - default: - throw json; + case 4111: // 4111 means the agent symbol has already been claimed so no server reset happened + await libContracts.contracts(); + await libShips.ships(); + return; + default: + throw json; } } db.reset(); + dbTokens.addToken(json.data.token); dbAgents.addAgent(json.data.agent); dbContracts.setContract(json.data.contract); dbShips.setShip(json.data.ship); - dbTokens.addToken(json.data.token); // Temporary fix to fetch the data on the startup probe - ships.ships(); + await libShips.ships(); } -- cgit v1.2.3