Skip to content

Commit

Permalink
fix: communication.callsignVhf not set properly in baseDeltas.json
Browse files Browse the repository at this point in the history
  • Loading branch information
sbender9 authored and tkurki committed Nov 23, 2024
1 parent b857dff commit 8fdca1a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
13 changes: 12 additions & 1 deletion src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`)
Expand Down
7 changes: 3 additions & 4 deletions src/serverroutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
Expand Down Expand Up @@ -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
)

Expand Down

0 comments on commit 8fdca1a

Please sign in to comment.