()
| 11 | import { useShowVersionUnsupportedAlert } from '../utils/hooks.js'; |
| 12 | |
| 13 | function VersionSupportedChecker(): React.Node { |
| 14 | const hasRun = React.useRef(false); |
| 15 | |
| 16 | const dispatchActionPromise = useDispatchActionPromise(); |
| 17 | const callVersionSupportedByIdentity = useVersionSupportedByIdentity(); |
| 18 | const showVersionUnsupportedAlert = useShowVersionUnsupportedAlert(true); |
| 19 | |
| 20 | const checkVersionSupport = React.useCallback(async () => { |
| 21 | try { |
| 22 | const versionSupportedPromise = callVersionSupportedByIdentity(); |
| 23 | void dispatchActionPromise( |
| 24 | versionSupportedByIdentityActionTypes, |
| 25 | versionSupportedPromise, |
| 26 | ); |
| 27 | const { supported: isVersionSupported } = await versionSupportedPromise; |
| 28 | if (isVersionSupported) { |
| 29 | return; |
| 30 | } |
| 31 | showVersionUnsupportedAlert(); |
| 32 | } catch (error) { |
| 33 | console.log('Error checking version:', error); |
| 34 | } |
| 35 | }, [ |
| 36 | callVersionSupportedByIdentity, |
| 37 | dispatchActionPromise, |
| 38 | showVersionUnsupportedAlert, |
| 39 | ]); |
| 40 | |
| 41 | React.useEffect(() => { |
| 42 | if (hasRun.current) { |
| 43 | return; |
| 44 | } |
| 45 | hasRun.current = true; |
| 46 | void checkVersionSupport(); |
| 47 | }, [checkVersionSupport]); |
| 48 | |
| 49 | return null; |
| 50 | } |
| 51 | |
| 52 | export default VersionSupportedChecker; |
nothing calls this directly
no test coverage detected