From 41cc07e30f95751e078434b9ed9438675c6f5272 Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 25 Dec 2023 08:31:26 +0300 Subject: [PATCH] search fix + some minor fixes --- src/components/Nav/AuthModal/LoginForm.tsx | 3 ++- src/components/Nav/HeaderAuth.tsx | 3 +-- src/components/Views/Author/Author.tsx | 9 --------- src/components/Views/Search.tsx | 5 ----- src/context/inbox.tsx | 2 +- src/stores/ui.ts | 10 +--------- 6 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/components/Nav/AuthModal/LoginForm.tsx b/src/components/Nav/AuthModal/LoginForm.tsx index 187a3e78..fcf76916 100644 --- a/src/components/Nav/AuthModal/LoginForm.tsx +++ b/src/components/Nav/AuthModal/LoginForm.tsx @@ -65,7 +65,8 @@ export const LoginForm = () => { setIsLinkSent(true) setIsEmailNotConfirmed(false) setSubmitError('') - changeSearchParams({ mode: 'forgot-password' }) // NOTE: temporary solition + changeSearchParams({ mode: 'forgot-password' }) + // NOTE: temporary solition, needs logix in authorizer /* FIXME: const { actions: { authorizer } } = useSession() const result = await authorizer().verifyEmail({ token }) diff --git a/src/components/Nav/HeaderAuth.tsx b/src/components/Nav/HeaderAuth.tsx index 8f2a9372..2b274940 100644 --- a/src/components/Nav/HeaderAuth.tsx +++ b/src/components/Nav/HeaderAuth.tsx @@ -196,8 +196,7 @@ export const HeaderAuth = (props: Props) => { >
- - {/*FIXME: replace with route*/} +
diff --git a/src/components/Views/Author/Author.tsx b/src/components/Views/Author/Author.tsx index 6a81e58a..c55ae33a 100644 --- a/src/components/Views/Author/Author.tsx +++ b/src/components/Views/Author/Author.tsx @@ -115,15 +115,6 @@ export const AuthorView = (props: Props) => { restoreScrollPosition() } - // TODO: use title - // const title = createMemo(() => { - // const m = searchParams().by - // if (m === 'viewed') return t('Top viewed') - // if (m === 'rating') return t('Top rated') - // if (m === 'commented') return t('Top discussed') - // return t('Top recent') - // }) - const pages = createMemo(() => splitToPages(sortedArticles(), PRERENDERED_ARTICLES_COUNT, LOAD_MORE_PAGE_SIZE), ) diff --git a/src/components/Views/Search.tsx b/src/components/Views/Search.tsx index 3fbadae6..db417713 100644 --- a/src/components/Views/Search.tsx +++ b/src/components/Views/Search.tsx @@ -54,11 +54,6 @@ export const SearchView = (props: Props) => { onMount(async () => { const q = window.location.pathname.replace('/search/', '') || props.query setQuery(q) - if (sortedArticles() && !sortedArticles()[0].created_at) { - // TODO: fill up articles data structures in search results - console.info('[SearchView] poor articles data structure found') - await loadMore() - } }) // TODO: use score from the search results to sort by relevance diff --git a/src/context/inbox.tsx b/src/context/inbox.tsx index 9872aea4..f518929c 100644 --- a/src/context/inbox.tsx +++ b/src/context/inbox.tsx @@ -56,7 +56,7 @@ export const InboxProvider = (props: { children: JSX.Element }) => { ): Promise> => { if (inboxClient.private) { const msgs = await inboxClient.loadChatMessages({ by, limit, offset }) - setMessages((mmm) => [...mmm, ...msgs]) // TODO: check unique + setMessages((mmm) => [...new Set([...mmm, ...msgs])]) return msgs || [] } return [] diff --git a/src/stores/ui.ts b/src/stores/ui.ts index 10180858..441b0b63 100644 --- a/src/stores/ui.ts +++ b/src/stores/ui.ts @@ -60,15 +60,7 @@ export const showModal = (modalType: ModalType, modalSource?: AuthModalSource) = setModal(modalType) } -// TODO: find a better solution -export const hideModal = () => { - const newSearchParams: Partial = { - modal: null, - source: null, - } - - setModal(null) -} +export const hideModal = () => setModal(null) export const useModalStore = () => { return {