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

feat(efb): Fix refresh of atc list issue during flight #5186

Merged
merged 28 commits into from
Jul 3, 2021
Merged
Changes from 24 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c37d88d
display page with the list of ATCs
ZeroKaa May 27, 2021
b4bb9bd
code simplification
ZeroKaa May 27, 2021
de71d86
fix sorting issue
ZeroKaa May 27, 2021
429bdae
clean console.log
ZeroKaa May 27, 2021
bc9b0b8
performance improvment
ZeroKaa May 27, 2021
87651a6
remove useless css file
ZeroKaa May 28, 2021
8d95683
add wrap for text atis
ZeroKaa Jun 14, 2021
7fd37c1
align with new api-client version
ZeroKaa Jun 15, 2021
9ff8d37
Merge branch 'flypados-v2' of https://github.com/flybywiresim/a32nx i…
ZeroKaa Jun 15, 2021
eb63dae
merge
ZeroKaa Jun 15, 2021
db6ab62
merge
ZeroKaa Jun 15, 2021
b7947e3
Revert "merge"
ZeroKaa Jun 16, 2021
6df3834
update api-client package
ZeroKaa Jun 16, 2021
ef45e2b
Update ATC.tsx
ZeroKaa Jun 16, 2021
d04ed0a
Revert "Update ATC.tsx"
ZeroKaa Jun 16, 2021
b3b1159
fix issue on atc list refresh
ZeroKaa Jun 16, 2021
1e3e78e
remove console.log
ZeroKaa Jun 16, 2021
c17baa3
add atis controllers in ATC page
ZeroKaa Jun 16, 2021
ea223d2
remove console.log
ZeroKaa Jun 16, 2021
234aa34
decrease refresh rate
ZeroKaa Jun 22, 2021
28fe087
Merge branch 'flypados-v2' of https://github.com/flybywiresim/a32nx i…
ZeroKaa Jun 22, 2021
fc726c9
fix refresh issue
ZeroKaa Jun 24, 2021
16b2a96
remove double load
ZeroKaa Jun 24, 2021
373e071
increase font-size
ZeroKaa Jun 24, 2021
6967808
fix distance calculation
ZeroKaa Jun 24, 2021
e983dbe
use useCallback and useInterval
ZeroKaa Jun 28, 2021
c72a812
add atisSource as dependency
ZeroKaa Jun 30, 2021
abe3d46
try to repect rules of hook
ZeroKaa Jun 30, 2021
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
15 changes: 10 additions & 5 deletions src/instruments/src/EFB/ATC/ATC.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ export const ATC = () => {
const [currentLatitude] = useSimVar('GPS POSITION LAT', 'Degrees', 5000);
const [currentLongitude] = useSimVar('GPS POSITION LON', 'Degrees', 5000);
const [atisSource] = usePersistentProperty('CONFIG_ATIS_SRC', 'FAA');
const [lastUpdate, setLastUpdate] = useState<string>();

useEffect(() => {
loadAtc();
setInterval(() => loadAtc(), 2 * 60 * 1000);
}, []);
const interval = setInterval(() => {
loadAtc();
setLastUpdate(new Date().toString());
}, 60 * 1000);

return () => clearInterval(interval);
}, [lastUpdate]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you added lastUpdate as a dependency to this hook? You're not using it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the hook executes everytime lastUpdate change.
I had to use this 'hack' otherwise the "currentLatitude" and "currentLongitude" wasn't updated within the setInterval()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case you're hiding the real dependencies currentLatitude and currentLongitude. You could refactor the loadAtc to use useCallback instead and make loadAtc a dependency. Or make currentLatitude and currentLongitude a parameter to loadAtc. The proposed change as-is is hacky and not robust at all.


useEffect(() => {
setAtc();
Expand Down Expand Up @@ -108,7 +113,7 @@ export const ATC = () => {
id="atc.callsign"
onClick={() => setFrequency(toFrequency(atc.frequency))}
>
<div className="flex w-full justify-start text-base">
<div className="flex w-full justify-start text-lg">
<div>
{ atc.type === apiClient.AtcType.RADAR && <IconChartRadar size="2rem" /> }
{ atc.type === apiClient.AtcType.GROUND && <IconTrafficLights size="2rem" /> }
Expand Down Expand Up @@ -157,7 +162,7 @@ export const ATC = () => {
</div>
<div className="active-atis flex-wrap mt-8 text-2xl">
{ currentAtc?.textAtis && currentAtc.textAtis.map((line) => (
<p className="flex flex-wrap mt-2">{line}</p>
<p className="flex text-base flex-wrap mt-2">{line}</p>
)) }
</div>
</div>
Expand Down