From 39e1321b04876bd1c6b4601fdf9298d90f08cdd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Mon, 16 Dec 2024 12:30:32 +0100 Subject: [PATCH] Fallback to latest version if unknown version is passed --- conanio/pages/center/recipes/[recipeName].tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/conanio/pages/center/recipes/[recipeName].tsx b/conanio/pages/center/recipes/[recipeName].tsx index b3bf182..4e856ed 100644 --- a/conanio/pages/center/recipes/[recipeName].tsx +++ b/conanio/pages/center/recipes/[recipeName].tsx @@ -83,8 +83,12 @@ const ConanPackage: NextPage = (props) => { useEffect(() => {hljs.highlightAll();}); - const [selectedVersion, setSelectedVersion] = useState(props.recipeVersion !== null? props.recipeVersion: props.data[0].info.version); - const indexSelectedVersion = Object.keys(props.data).filter(index => props.data[index].info.version === selectedVersion)[0]; + let [selectedVersion, setSelectedVersion] = useState(props.recipeVersion !== null? props.recipeVersion: props.data[0].info.version); + let indexSelectedVersion = Object.keys(props.data).filter(index => props.data[index].info.version === selectedVersion)[0]; + if (indexSelectedVersion == null) { + indexSelectedVersion = "0"; + selectedVersion = props.data[0].info.version; + } const isTabletOrMobile = useMediaQuery({ query: '(max-width: 1224px)' }) const [selectedTab, setSelectedTab] = useState(indexSelectedVersion && props.data[indexSelectedVersion].info.status === "ok"? 'use_it': 'versions'); const [packageOS, setPackageOS] = useState(null);