diff --git a/src/config/config.ts b/src/config/config.ts index e11ec0aaf..562e13d6e 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -330,8 +330,19 @@ function getFullDefaults(app: ConfigApp) { function setBaseDeltas(app: ConfigApp) { const defaultsPath = getBaseDeltasPath(app) try { - app.config.baseDeltaEditor.load(defaultsPath) + const de = app.config.baseDeltaEditor + + de.load(defaultsPath) debug(`Found default deltas at ${defaultsPath.toString()}`) + + //fix old, incorrectly done callsignVhf + const communication = de.getSelfValue('communication') + if (communication) { + if (communication.callsignVhf) { + de.setSelfValue('communication.callsignVhf', communication.callsignVhf) + } + de.setSelfValue('communication', undefined) + } } catch (e) { if ((e as any)?.code === 'ENOENT') { debug(`No default deltas found at ${defaultsPath.toString()}`) diff --git a/src/serverroutes.ts b/src/serverroutes.ts index 6fd14764e..894d079a8 100644 --- a/src/serverroutes.ts +++ b/src/serverroutes.ts @@ -658,7 +658,6 @@ module.exports = function ( app.get(`${SERVERROUTESPREFIX}/vessel`, (req: Request, res: Response) => { const de = app.config.baseDeltaEditor - const communication = de.getSelfValue('communication') const draft = de.getSelfValue('design.draft') const length = de.getSelfValue('design.length') const type = de.getSelfValue('design.aisShipType') @@ -673,7 +672,7 @@ module.exports = function ( gpsFromBow: de.getSelfValue('sensors.gps.fromBow'), gpsFromCenter: de.getSelfValue('sensors.gps.fromCenter'), aisShipType: type && type.id, - callsignVhf: communication && communication.callsignVhf + callsignVhf: de.getSelfValue('communication.callsignVhf') } res.json(json) @@ -814,9 +813,9 @@ module.exports = function ( : undefined ) de.setSelfValue( - 'communication', + 'communication.callsignVhf', !isUndefined(vessel.callsignVhf) && vessel.callsignVhf.length - ? { callsignVhf: vessel.callsignVhf } + ? vessel.callsignVhf : undefined )