@@ -71,14 +71,18 @@ const Page: React.FC = ({ deviceType, deviceOs }) => { const includeParams = useAppSelector((state) => state.params.params) const dispatch = useDispatch() + const { push } = useRouter() + const deleteMessageMemo = useCallback(deleteMessage, [currentChat, messages]) React.useEffect(() => { if (data?.access) { model_api.getBotParams(router.asPath.split('/')[2], data.access).then((res) => { + if (!res.title) return push('/404') + setBotParams(res) setModelType(res.slug) - if (res.versions.length !== 0) { + if (res.versions && res.versions.length !== 0) { setVersion(res.versions[0].slug) dispatch( setParametres( @@ -91,7 +95,7 @@ const Page: React.FC = ({ deviceType, deviceOs }) => { ) ) ) - } else { + } else if (res.parameters) { setVersion('') dispatch( setParametres( @@ -246,28 +250,32 @@ const Page: React.FC = ({ deviceType, deviceOs }) => { createNewChat={createNewChat} handleClickChatSetting={handleClickChatSetting} /> - {desktop && ( - - {botParams?.versions && botParams.versions?.length !== 0 && ( - <> - - ВЕРСИИ - - - - )} + {desktop && botParams && ( + + {botParams?.versions && + botParams.versions?.length !== 0 && ( + <> + + ВЕРСИИ + + + + )} {botParams && botParams.parameters?.length > 0 && ( = ({ deviceType, deviceOs }) => { onClose={hideMobileSettings} > - {botParams?.versions && botParams.versions?.length !== 0 && ( - <> - - ВЕРСИИ - - - - )} + {botParams?.versions && + botParams.versions?.length !== 0 && ( + <> + + ВЕРСИИ + + + + )} {botParams && botParams.parameters?.length > 0 ? ( <> = ({ deviceType, deviceOs }) => { const includeParams = useAppSelector((state) => state.params.params) const dispatch = useDispatch() - const { messages, loading, createImage, isComplete, getMessagesPagination } = useModelImages(showError, modelType, deviceType) + const { messages, loading, createImage, isComplete, getMessagesPagination } = + useModelImages(showError, modelType, deviceType) const [chatScrollHeight, setChatScrollHeight] = React.useState(0) const [scrollBottom, setScrollBottom] = React.useState(0) const refScrollMobile = useRef() const [isPaginating, setIsPaginating] = React.useState(false) + const { push } = useRouter() + React.useEffect(() => { + if (!data) return model_api - .getBotParams(router.asPath.split('/')[2], data?.access) + .getBotParams(router.asPath.split('/')[2], data.access) .then((res) => { + if (!res.title) return push('/404') + setBotParams(res) setModelType(res.slug) if (res.versions.length !== 0) { @@ -219,7 +225,11 @@ const Images: React.FC = ({ deviceType, deviceOs }) => { }, [isComplete]) const handleMobileScroll = () => { - setScrollBottom(refScrollMobile.current?.scrollHeight - refScrollMobile.current?.scrollTop - refScrollMobile.current?.clientHeight) + setScrollBottom( + refScrollMobile.current?.scrollHeight - + refScrollMobile.current?.scrollTop - + refScrollMobile.current?.clientHeight + ) if (refScrollMobile.current && messages?.length !== 0) { const { scrollTop, scrollHeight, clientHeight } = refScrollMobile.current