From 7c614c66d9e02f70fe244bd5ed54f50d5b62704f Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 30 Aug 2024 16:45:17 +0300 Subject: [PATCH] minor-ref --- src/components/Article/CommentsTree.tsx | 2 +- src/components/SearchModal/SearchModal.tsx | 4 +- src/components/TopicsNav/TopicsNav.tsx | 6 +- .../Views/AllAuthors/AllAuthors.tsx | 2 +- src/components/Views/AllTopics/AllTopics.tsx | 2 +- src/components/Views/Author/Author.tsx | 2 +- src/components/Views/Feed/Feed.tsx | 2 +- .../Views/Profile/ProfileSettings.tsx | 2 +- .../Views/Profile/ProfileSubscriptions.tsx | 2 +- .../Views/Profile}/profileSocialLinks.ts | 0 src/components/_shared/LoadMoreWrapper.tsx | 2 +- src/context/authors.tsx | 2 +- src/context/feed.tsx | 2 +- src/context/topics.tsx | 6 +- src/{lib => intl}/dummyFilter.ts | 2 +- src/lib/getRandomTopicsFromArray.ts | 8 --- src/lib/sort.ts | 59 ------------------- src/utils/random.ts | 8 +++ src/utils/sort.ts | 57 ++++++++++++++++++ 19 files changed, 84 insertions(+), 86 deletions(-) rename src/{lib => components/Views/Profile}/profileSocialLinks.ts (100%) rename src/{lib => intl}/dummyFilter.ts (96%) delete mode 100644 src/lib/getRandomTopicsFromArray.ts delete mode 100644 src/lib/sort.ts create mode 100644 src/utils/random.ts create mode 100644 src/utils/sort.ts diff --git a/src/components/Article/CommentsTree.tsx b/src/components/Article/CommentsTree.tsx index 13fffae5..299c62a1 100644 --- a/src/components/Article/CommentsTree.tsx +++ b/src/components/Article/CommentsTree.tsx @@ -6,8 +6,8 @@ import { useLocalize } from '~/context/localize' import { useReactions } from '~/context/reactions' import { useSession } from '~/context/session' import { Author, Reaction, ReactionKind, ReactionSort } from '~/graphql/schema/core.gen' -import { byCreated, byStat } from '~/lib/sort' import { SortFunction } from '~/types/common' +import { byCreated, byStat } from '~/utils/sort' import { Button } from '../_shared/Button' import { ShowIfAuthenticated } from '../_shared/ShowIfAuthenticated' import styles from './Article.module.scss' diff --git a/src/components/SearchModal/SearchModal.tsx b/src/components/SearchModal/SearchModal.tsx index 5545f1c2..b0ef9644 100644 --- a/src/components/SearchModal/SearchModal.tsx +++ b/src/components/SearchModal/SearchModal.tsx @@ -5,8 +5,8 @@ import { Icon } from '~/components/_shared/Icon' import { useFeed } from '~/context/feed' import { useLocalize } from '~/context/localize' import type { Shout } from '~/graphql/schema/core.gen' -import { byScore } from '~/lib/sort' import { restoreScrollPosition, saveScrollPosition } from '~/utils/scroll' +import { byScore } from '~/utils/sort' import { FEED_PAGE_SIZE } from '../Views/Feed/Feed' import styles from './SearchModal.module.scss' import { SearchResultItem } from './SearchResultItem' @@ -23,7 +23,7 @@ const getSearchCoincidences = ({ str, intersection }: { str: string; intersectio )}` const prepareSearchResults = (list: Shout[], searchValue: string) => - list.sort(byScore() as (a: Shout, b: Shout) => number).map((article, index) => ({ + list.sort(byScore as (a: Shout, b: Shout) => number).map((article, index) => ({ ...article, id: index, title: article.title diff --git a/src/components/TopicsNav/TopicsNav.tsx b/src/components/TopicsNav/TopicsNav.tsx index 2a4f5395..c6f1801a 100644 --- a/src/components/TopicsNav/TopicsNav.tsx +++ b/src/components/TopicsNav/TopicsNav.tsx @@ -5,7 +5,7 @@ import { Icon } from '~/components/_shared/Icon' import { useLocalize } from '~/context/localize' import { useTopics } from '~/context/topics' import type { Topic } from '~/graphql/schema/core.gen' -import { getRandomTopicsFromArray } from '~/lib/getRandomTopicsFromArray' +import { getRandomItemsFromArray } from '~/utils/random' import styles from './TopicsNav.module.scss' export const RandomTopics = () => { @@ -17,11 +17,11 @@ export const RandomTopics = () => { createEffect( on(sortedTopics, (ttt: Topic[]) => { if (ttt?.length) { - setRandomTopics(getRandomTopicsFromArray(ttt)) + setRandomTopics(getRandomItemsFromArray(ttt)) } }) ) - onMount(() => sortedTopics() && getRandomTopicsFromArray(sortedTopics())) + onMount(() => sortedTopics() && getRandomItemsFromArray(sortedTopics())) return (