MCPcopy Create free account
hub / github.com/CommE2E/comm / VersionSupportedChecker

Function VersionSupportedChecker

native/components/version-supported.react.js:13–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11import { useShowVersionUnsupportedAlert } from '../utils/hooks.js';
12
13function 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
52export default VersionSupportedChecker;

Callers

nothing calls this directly

Calls 5

useDispatchActionPromiseFunction · 0.90
dispatchActionPromiseFunction · 0.85
logMethod · 0.45

Tested by

no test coverage detected