From dd045ee6fe1406c6787bacaa70a6aecb464abebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=B0=D1=81=D1=83=D0=BB?= Date: Wed, 14 Feb 2024 13:11:27 +0300 Subject: [PATCH] fix: revert add content modal changes --- src/components/AddContentModal/index.tsx | 52 ++----------------- src/components/App/SideBar/Image/index.tsx | 2 - .../App/SideBar/Relevance/index.tsx | 9 ++-- src/components/App/index.tsx | 3 -- .../AddNodeEdgeModal/Body/index.tsx | 3 -- .../Title/Autocomplete/index.tsx | 2 - .../SettingsView/General/index.tsx | 2 - .../SettingsModal/SettingsView/index.tsx | 2 - .../Title/Autocomplete/index.tsx | 2 - 9 files changed, 9 insertions(+), 68 deletions(-) diff --git a/src/components/AddContentModal/index.tsx b/src/components/AddContentModal/index.tsx index ca382c86f..5b8827280 100644 --- a/src/components/AddContentModal/index.tsx +++ b/src/components/AddContentModal/index.tsx @@ -34,17 +34,6 @@ export type FormData = { latitude: string } -interface ApiResponse { - status: number - source?: string - content?: string -} - -interface ApiError { - status: number - message?: string -} - const handleSubmitForm = async ( data: FieldValues, close: () => void, @@ -159,8 +148,6 @@ export const AddContentModal = () => { const form = useForm({ mode: 'onChange' }) const { watch, setValue, reset } = form const [loading, setLoading] = useState(false) - const [isSourceRes, setIsSourceRes] = useState(false) - const [isContentRes, setIsContentRes] = useState(false) useEffect( () => () => { @@ -188,38 +175,8 @@ export const AddContentModal = () => { close() } - const onNextStep = async () => { - if (currentStep === 0) { - try { - const data = { source } - - const response = (await api.post('/validate_content', JSON.stringify(data))) as ApiResponse - - if (response.status === 404 || response.status === 400) { - notify('Please enter a valid URL') - reset() - - return - } - - if (response.source) { - setIsSourceRes(true) - setCurrentStep(currentStep + 1) - } - - if (response.content) { - setIsContentRes(true) - setCurrentStep(currentStep + 1) - } - } catch (e) { - const error = e as ApiError - - if (error.status === 404 || error.status === 400) { - notify('Please enter a valid URL') - reset() - } - } - } + const onNextStep = () => { + setCurrentStep(currentStep + 1) } const onPrevStep = () => { @@ -245,10 +202,9 @@ export const AddContentModal = () => { {currentStep === 0 && } {currentStep === 1 && ( <> - {isSourceRes && ( + {!isSource(type) ? ( - )} - {isContentRes && ( + ) : ( )} diff --git a/src/components/App/SideBar/Image/index.tsx b/src/components/App/SideBar/Image/index.tsx index 1e99d3030..14800e902 100644 --- a/src/components/App/SideBar/Image/index.tsx +++ b/src/components/App/SideBar/Image/index.tsx @@ -8,8 +8,6 @@ export const Image = () => { const imageName = selectedNode?.name - console.log(selectedNode) - return ( diff --git a/src/components/App/SideBar/Relevance/index.tsx b/src/components/App/SideBar/Relevance/index.tsx index 7521593bc..fb66b52b9 100644 --- a/src/components/App/SideBar/Relevance/index.tsx +++ b/src/components/App/SideBar/Relevance/index.tsx @@ -1,5 +1,5 @@ import { Button } from '@mui/material' -import { useCallback, useMemo, useRef, useState } from 'react' +import { memo, useCallback, useMemo, useRef, useState } from 'react' import styled from 'styled-components' import { ScrollView } from '~/components/ScrollView' import { Flex } from '~/components/common/Flex' @@ -15,7 +15,8 @@ type Props = { isSearchResult: boolean } -export const Relevance = ({ isSearchResult }: Props) => { +// eslint-disable-next-line no-underscore-dangle +const _Relevance = ({ isSearchResult }: Props) => { const scrollViewRef = useRef(null) const pageSize = !isSearchResult ? 10 : 80 @@ -28,8 +29,6 @@ export const Relevance = ({ isSearchResult }: Props) => { const filteredNodes = useFilteredNodes() - console.log(filteredNodes) - const startSlice = currentPage * pageSize const endSlice = startSlice + pageSize @@ -115,6 +114,8 @@ export const Relevance = ({ isSearchResult }: Props) => { ) } +export const Relevance = memo(_Relevance) + const LoadMoreWrapper = styled(Flex)` flex: 0 0 86px; ` diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index ea964733d..c820bcbec 100644 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -119,8 +119,6 @@ export const App = () => { console.error('Socket connection error:', error) }) - socket.on('connect', () => console.log('connected')) - socket.on('disconnect', () => console.log('disconnected')) socket.on('newnode', handleNewNode) } }, [socket, handleNewNode]) @@ -128,7 +126,6 @@ export const App = () => { useEffect( () => () => { if (socket) { - console.log('disc') socket.disconnect() } }, diff --git a/src/components/ModalsContainer/AddNodeEdgeModal/Body/index.tsx b/src/components/ModalsContainer/AddNodeEdgeModal/Body/index.tsx index 24091b0b7..b4a0a811e 100644 --- a/src/components/ModalsContainer/AddNodeEdgeModal/Body/index.tsx +++ b/src/components/ModalsContainer/AddNodeEdgeModal/Body/index.tsx @@ -23,8 +23,6 @@ export const Body = () => { const [topicIsLoading, setTopicIsLoading] = useState(false) const [selectedTopic, setSelectedTopic] = useState(null) - console.log(topicIsLoading) - const [actualNode, setActualNode] = useState() const selectedNode = useSelectedNode() @@ -45,7 +43,6 @@ export const Body = () => { setActualNode(node) } catch (error) { console.log(error) - console.log(error) } finally { setTopicIsLoading(false) } diff --git a/src/components/ModalsContainer/AddNodeEdgeModal/Title/Autocomplete/index.tsx b/src/components/ModalsContainer/AddNodeEdgeModal/Title/Autocomplete/index.tsx index 6a365e77b..62209d5fa 100644 --- a/src/components/ModalsContainer/AddNodeEdgeModal/Title/Autocomplete/index.tsx +++ b/src/components/ModalsContainer/AddNodeEdgeModal/Title/Autocomplete/index.tsx @@ -40,8 +40,6 @@ export const DropdownSearch: React.FC = ({ onSelect, selectedTopic }) => try { const responseData: FetchTopicResponse = await getTopicsData(filters) - console.log(responseData.data) - setOptions(responseData.data) } catch (error) { setOptions([]) diff --git a/src/components/SettingsModal/SettingsView/General/index.tsx b/src/components/SettingsModal/SettingsView/General/index.tsx index 530fba402..21e3efe1b 100644 --- a/src/components/SettingsModal/SettingsView/General/index.tsx +++ b/src/components/SettingsModal/SettingsView/General/index.tsx @@ -23,8 +23,6 @@ export const General: FC = ({ initialValues }) => { try { const res = (await postAboutData(data)) as Awaited<{ status: string }> - console.log(res) - if (res.status === 'success') { setAppMetaData(data) } diff --git a/src/components/SettingsModal/SettingsView/index.tsx b/src/components/SettingsModal/SettingsView/index.tsx index f7ffd2e53..0f2ab6cf2 100644 --- a/src/components/SettingsModal/SettingsView/index.tsx +++ b/src/components/SettingsModal/SettingsView/index.tsx @@ -50,8 +50,6 @@ export const SettingsView: React.FC = ({ onClose }) => { const [isAdmin, pubKey] = useUserStore((s) => [s.isAdmin, s.setPubKey, s.pubKey]) const appMetaData = useAppStore((s) => s.appMetaData) - console.log(appMetaData) - const getSettingsLabel = () => (isAdmin ? 'Admin Settings' : 'Settings') const SettingsHeader = ({ children }: { children: React.ReactNode }) => ( diff --git a/src/components/SourcesTableModal/SourcesView/Topics/AddEdgeTopicModal/Title/Autocomplete/index.tsx b/src/components/SourcesTableModal/SourcesView/Topics/AddEdgeTopicModal/Title/Autocomplete/index.tsx index 6a365e77b..62209d5fa 100644 --- a/src/components/SourcesTableModal/SourcesView/Topics/AddEdgeTopicModal/Title/Autocomplete/index.tsx +++ b/src/components/SourcesTableModal/SourcesView/Topics/AddEdgeTopicModal/Title/Autocomplete/index.tsx @@ -40,8 +40,6 @@ export const DropdownSearch: React.FC = ({ onSelect, selectedTopic }) => try { const responseData: FetchTopicResponse = await getTopicsData(filters) - console.log(responseData.data) - setOptions(responseData.data) } catch (error) { setOptions([])