@@ -15,32 +15,14 @@ const PLATFORM_VERSIONS = publicRuntimeConfig.PLATFORM_VERSIONS;
1515const  PLATFORM_LATEST_VERSIONS  =  publicRuntimeConfig . PLATFORM_LATEST_VERSIONS ; 
1616const  PLATFORMS  =  publicRuntimeConfig . PLATFORMS ; 
1717
18- export  function  VersionContextProvider ( {  children } )  { 
19-   const  [ initialized ,  setInitialized ]  =  useState ( false ) ; 
20- 
21-   const  [ version ,  setVersionState ]  =  useState ( DEFAULT_VERSION ) ; 
22-   const  [ platform ,  setPlatformState ]  =  useState ( DEFAULT_PLATFORM ) ; 
23-   // const [isOpen, setIsOpen] = useState(false); 
24-   const  router  =  useRouter ( ) ; 
25- 
26-   const  initialize  =  useCallback ( 
27-     ( {  newVersion,  newPlatform,  functionName =  null ,  currMenuItem =  null  } )  =>  { 
28-       if  ( initialized )  return  [ version ,  platform ] ; 
29- 
30-       setVersionAndPlatform ( { 
31-         newVersion, 
32-         newPlatform, 
33-         functionName, 
34-         currMenuItem, 
35-         updateURL : true , 
36-       } ) ; 
37- 
38-       setInitialized ( true ) ; 
39- 
40-       return  [ newVersion ,  newPlatform ] ; 
41-     } , 
42-     [ initialized ,  version ,  platform ] , 
18+ export  function  VersionContextProvider ( props )  { 
19+   const  [ platform ,  setPlatformState ]  =  useState ( ( )  => 
20+     getCleanedPlatform ( props . platformFromStaticLoad ) , 
21+   ) ; 
22+   const  [ version ,  setVersionState ]  =  useState ( ( )  => 
23+     getCleanedVersion ( props . versionFromStaticLoad ,  platform ) , 
4324  ) ; 
25+   const  router  =  useRouter ( ) ; 
4426
4527  const  setVersionAndPlatform  =  useCallback ( 
4628    ( { 
@@ -63,12 +45,10 @@ export function VersionContextProvider({ children }) {
6345        return ; 
6446      } 
6547
66-       const  cleanedVersion  =  isLatestVersion ( newVersion ,  newPlatform ) 
67-         ? DEFAULT_VERSION 
68-         : newVersion ; 
69-       setVersionState ( cleanedVersion ) ; 
48+       const  cleanedVersion  =  getCleanedVersion ( newVersion ,  newPlatform ) ; 
49+       const  cleanedPlatform  =  getCleanedPlatform ( newPlatform ) ; 
7050
71-       const   cleanedPlatform   =   newPlatform   ??   DEFAULT_PLATFORM ; 
51+       setVersionState ( cleanedVersion ) ; 
7252      setPlatformState ( cleanedPlatform ) ; 
7353
7454      if  ( updateURL )  { 
@@ -96,15 +76,14 @@ export function VersionContextProvider({ children }) {
9676      value = { { 
9777        version, 
9878        platform, 
99-         initialize, 
10079        setVersionAndPlatform, 
10180        goToLatest, 
10281        goToOpenSource, 
10382        // isOpen, 
10483        // setIsOpen 
10584      } } 
10685    > 
107-       { children } 
86+       { props . children } 
10887    </ Context . Provider > 
10988  ) ; 
11089} 
@@ -219,8 +198,8 @@ export function getVersionAndPlatformFromPathPart(pathPart) {
219198export  function  versionAndPlatformAreCompatible ( version ,  platform )  { 
220199  if  ( version  ==  DEFAULT_VERSION )  return  true ; 
221200
222-   if  ( platform  ==  DEFAULT_PLATFORM   &&   VERSIONS_LIST . indexOf ( version )   >=   0 )  { 
223-     return  true ; 
201+   if  ( platform  ==  DEFAULT_PLATFORM )  { 
202+     return  VERSIONS_LIST . indexOf ( version )   >=   0 ; 
224203  } 
225204
226205  return  PLATFORM_VERSIONS [ platform ] . indexOf ( version )  >=  0 ; 
@@ -252,3 +231,11 @@ export function getBestNumericVersion(version, platform) {
252231    } 
253232  } 
254233} 
234+ 
235+ function  getCleanedVersion ( version ,  platform )  { 
236+   return  isLatestVersion ( version ,  platform )  ? DEFAULT_VERSION  : version ; 
237+ } 
238+ 
239+ function  getCleanedPlatform ( platform )  { 
240+   return  platform  ??  DEFAULT_PLATFORM ; 
241+ } 
0 commit comments