Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(efb): disambiguate navigraph sub status #9793

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
1. [ATSU] Add MSFS as TAF source in MSFS2024 - @tracernz (Mike)
1. [A380X/MFD] Fix wrong Landing weight calculation & block fuel not editable across flights in FUEL & LOAD - @BravoMike99 (bruno_pt99)
1. [A32NX/FMS] Add terminal area database holds for MSFS2024 - @tracernz (Mike)
1. [EFB] Navigraph subscriptions other than Ultimate are now shown on the EFB to reduce confusion with "Unknown" - @tracernz (Mike)

## 0.12.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { NavigraphKeys, NavigraphSubscriptionStatus } from '@flybywiresim/fbw-sd
import { useHistory } from 'react-router-dom';
import { t } from '../../../Localization/translation';
import { useNavigraphAuth } from '../../../../react/navigraph';
import { CancelToken } from '@navigraph/auth';
import { CancelToken, User } from '@navigraph/auth';

const NAVIGRAPH_SUBSCRIPTION_CHARTS = 'charts';
const NAVIGRAPH_SUBSCRIPTION_FMSDATA = 'fmsdata';
Expand All @@ -27,6 +27,20 @@ export type NavigraphAuthInfo =
subscriptionStatus: NavigraphSubscriptionStatus;
};

function getNavigraphSubscriptionStatus(user: User) {
switch (true) {
case user.subscriptions.length === 0:
return NavigraphSubscriptionStatus.None;
case [NAVIGRAPH_SUBSCRIPTION_CHARTS, NAVIGRAPH_SUBSCRIPTION_FMSDATA].every((it) => user.subscriptions.includes(it)):
return NavigraphSubscriptionStatus.Unlimited;
case user.subscriptions.includes(NAVIGRAPH_SUBSCRIPTION_FMSDATA):
// no longer offered but people may have on longer-term subscription
return NavigraphSubscriptionStatus.Standard;
default:
return NavigraphSubscriptionStatus.Unknown;
}
}

export const useNavigraphAuthInfo = (): NavigraphAuthInfo => {
const [info, setInfo] = useState<NavigraphAuthInfo>({ loggedIn: false });

Expand All @@ -36,11 +50,7 @@ export const useNavigraphAuthInfo = (): NavigraphAuthInfo => {
setInfo({
loggedIn: true,
username: navigraphAuth.user.preferred_username,
subscriptionStatus: [NAVIGRAPH_SUBSCRIPTION_CHARTS, NAVIGRAPH_SUBSCRIPTION_FMSDATA].every((it) =>
navigraphAuth.user.subscriptions.includes(it),
)
? NavigraphSubscriptionStatus.Unlimited
: NavigraphSubscriptionStatus.Unknown,
subscriptionStatus: getNavigraphSubscriptionStatus(navigraphAuth.user),
});
} else if (!navigraphAuth.user && info.loggedIn === true) {
setInfo({ loggedIn: false });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@
"Unlink": "Unlink Account",
"SubscriptionStatus": {
"None": "None",
"Standard": "Navigraph Standard",
"Unlimited": "Navigraph Unlimited",
"Unknown": "Unknown"
},
Expand Down
1 change: 1 addition & 0 deletions fbw-common/src/systems/shared/src/navigraph/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Chart } from 'navigraph/charts';

export enum NavigraphSubscriptionStatus {
None,
Standard,
Unlimited,
Unknown,
}
Expand Down
Loading