Skip to content

Commit

Permalink
refactor: simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tracernz committed Jan 18, 2025
1 parent 39c49d3 commit 471b1ef
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions fbw-common/src/systems/datalink/router/src/msfs/MsfsConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@ export class MsfsConnector {
}

public static async receiveMsfsTaf(icao: string, message: WeatherMessage): Promise<AtsuStatusCodes> {
let report: string | undefined;
if (isMsfs2024()) {
try {
const taf: { tafString: string; icao: string } = await Coherent.call('GET_TAF_BY_IDENT', icao);
let report = taf.tafString;
if (!report || taf.icao !== icao) {
report = 'NO TAF AVAILABLE';
if (taf.tafString && taf.icao === icao) {
report = taf.tafString;
}
message.Reports.push({ airport: icao, report });
return AtsuStatusCodes.Ok;
} catch {
message.Reports.push({ airport: icao, report: 'NO TAF AVAILABLE' });
return AtsuStatusCodes.Ok;
} catch (e) {
console.log('receiveMsfsTaf: Failed', e);
}
}
message.Reports.push({ airport: icao, report: 'NO TAF AVAILABLE' });
message.Reports.push({ airport: icao, report: report ?? 'NO TAF AVAILABLE' });
return AtsuStatusCodes.Ok;
}
}

0 comments on commit 471b1ef

Please sign in to comment.