From 4c1a5fdfe1fb99901a24bfdd9d5c42a6939e6dd8 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 14 Sep 2023 00:02:51 +0200 Subject: [javascript] improved contract lib --- nodejs/lib/contracts.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'nodejs/lib') diff --git a/nodejs/lib/contracts.js b/nodejs/lib/contracts.js index e4ba2ae..f73f297 100644 --- a/nodejs/lib/contracts.js +++ b/nodejs/lib/contracts.js @@ -1,9 +1,16 @@ import * as dbContracts from '../database/contracts.js'; import * as api from './api.js'; import * as dbShips from '../database/ships.js'; +import * as libShips from '../lib/ships.js'; export async function accept(ctx) { - return await api.send({endpoint: `/my/contracts/${ctx.contract}/accept`, method: 'POST'}); + const contract = dbContracts.getContract(ctx.id); + if (contract.accepted) { + return; + } + await api.send({endpoint: `/my/contracts/${ctx.id}/accept`, method: 'POST'}); + contract.accepted = true; + dbContracts.setContract(contract); } export async function contracts() { -- cgit v1.2.3