Closed bxmatus closed 4 months ago
If you aren't getting altitude, it is an API problem - both possible keys for altitude (EGM96
and WGS84
) are initialised with default values of 0
. These values are updated by the forPullKey
listener provided by @ritirl/api
, like all other variables throughout the app as per:
const useListener = () => {
const { pullKey } = keyStore.get();
useEffect(() => {
const unsubscribeListener = forPullKey(pullKey).addListener((data: IListenerProps) => {
globalStore.set((prevState) => ({
...prevState,
altitude: data.altitude,
heading: data.heading,
location: data.location,
speed: (data.speed * 3.6),
}));
});
const unsubscribeSessionListener = forPullKey(pullKey).addListener((data: ISessionListenerProps) => {
globalStore.set((prevState) => ({
...prevState,
sessionId: data.sessionId,
}));
});
return () => {
unsubscribeListener()
unsubscribeSessionListener()
};
});
};
This fix serves no purpose - you will already get 0
displayed if for some reason the API is not returning altitude.
The current situation is that when you download and run react-realtimeirl, you will get an error in the browser:
Altitude.tsx:10 Uncaught TypeError: Cannot read properties of undefined (reading 'EGM96') at Altitude (Altitude.tsx:10:67) at renderWithHooks (react-dom.development.js:16305:18) at updateFunctionComponent (react-dom.development.js:19588:20) at beginWork (react-dom.development.js:21601:16) at HTMLUnknownElement.callCallback2 (react-dom.development.js:4164:14) at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:16) at invokeGuardedCallback (react-dom.development.js:4277:31) at beginWork$1 (react-dom.development.js:27451:7) at performUnitOfWork (react-dom.development.js:26557:12) at workLoopSync (react-dom.development.js:26466:5)
My code is fixing it, but it's your code and your decision. I was just trying to help people using it.
Map redacted for privacy, but, no - I just freshly downloaded and spun this up with all my keys on a brand new Linux installation, and no errors at all. Provide your system configuration, screenshots, error messages, or any other information that might actually assist in helping you.
Im running linux, hosting1 ~ # docker --version Docker version 20.10.22, build 3a2c30b63a And on browser is clean white screen ( there is map for a second then it disappear ). When i apply my small change everything working perfectly fine.
I can't replicate your issue in Docker either.
There are only two possible reasons for this, either you've modified something elsewhere in the codebase which has caused this issue, or there's an issue with the API specific to your location/pull key.
I would suggest you prune the Docker container/image and start over. Failing that, you'll need to visit the Muxable discord so we can look into your pull key and the data the API is returning for it.
Appreciate you trying to help but what you propose isn't a fix, and you're the first person in 2 years to ever encounter this problem. If the API is returning undefined, the API needs to be fixed - it is not possible for this code to return undefined.
I know what is the problem, only lat and long are mandatory values in Muxable API, rest is optional. I'm not using an app for pushing data but my own software which is sending only mandatory values. This is the reason why it's not working only for me. I assume the app is always sending altitude.
Matus
čt 11. 7. 2024 v 10:36 odesílatel Sam @.***> napsal:
Closed #5 https://github.com/scallensc/react-realtimeirl/issues/5 as completed.
— Reply to this email directly, view it on GitHub https://github.com/scallensc/react-realtimeirl/issues/5#event-13468181395, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4QIOUHXG6VCXECZ7J7AB3ZLY7ZJAVCNFSM6AAAAABKURMV3GVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJTGQ3DQMJYGEZTSNI . You are receiving this because you authored the thread.Message ID: @.***>
There is a small issue when altitude is missing. Here is corrected Altitude.tsx file which is fixing it:
import valueFormatter from "@functions/valueFormatter"; import flagStore from "@store/flagStore"; import globalStore from "@store/globalStore";
const Altitude = () => { const { showAltitude, useImperial } = flagStore.get(); const { altitude } = globalStore.get();
// Check if altitude and altitude['EGM96'] are defined if (!altitude || !altitude['EGM96']) { return null; }
const { metric, imperial } = valueFormatter('altitude', altitude['EGM96']);
return ( <div className="altitude-text" style={{ display: showAltitude ? '' : 'none' }}> Altitude: {useImperial ? imperial : metric}
export default Altitude;