diff --git a/src/components/Article/CommentsTree.tsx b/src/components/Article/CommentsTree.tsx index 8546e4ba..ef04a3a9 100644 --- a/src/components/Article/CommentsTree.tsx +++ b/src/components/Article/CommentsTree.tsx @@ -5,7 +5,7 @@ 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/sortBy' +import { byCreated, byStat } from '~/lib/sort' import { Button } from '../_shared/Button' import { ShowIfAuthenticated } from '../_shared/ShowIfAuthenticated' diff --git a/src/components/Nav/SearchModal/SearchModal.tsx b/src/components/Nav/SearchModal/SearchModal.tsx index 2c815076..1e43e20c 100644 --- a/src/components/Nav/SearchModal/SearchModal.tsx +++ b/src/components/Nav/SearchModal/SearchModal.tsx @@ -7,7 +7,7 @@ import { Button } from '~/components/_shared/Button' import { Icon } from '~/components/_shared/Icon' import { useFeed } from '~/context/feed' import { useLocalize } from '~/context/localize' -import { byScore } from '~/lib/sortBy' +import { byScore } from '~/lib/sort' import { restoreScrollPosition, saveScrollPosition } from '~/utils/scroll' import { FEED_PAGE_SIZE } from '../../Views/Feed/Feed' diff --git a/src/components/Views/AllAuthors/AllAuthors.tsx b/src/components/Views/AllAuthors/AllAuthors.tsx index 6ac67afe..1bd2388b 100644 --- a/src/components/Views/AllAuthors/AllAuthors.tsx +++ b/src/components/Views/AllAuthors/AllAuthors.tsx @@ -11,7 +11,7 @@ import { useLocalize } from '~/context/localize' import type { Author } from '~/graphql/schema/core.gen' import { authorLetterReduce, translateAuthor } from '~/intl/translate' import { dummyFilter } from '~/lib/dummyFilter' -import { byFirstChar, byStat } from '~/lib/sortBy' +import { byFirstChar, byStat } from '~/lib/sort' import { scrollHandler } from '~/utils/scroll' import styles from './AllAuthors.module.scss' import stylesAuthorList from './AuthorsList.module.scss' diff --git a/src/components/Views/Author/Author.tsx b/src/components/Views/Author/Author.tsx index e9c6aecf..e995956b 100644 --- a/src/components/Views/Author/Author.tsx +++ b/src/components/Views/Author/Author.tsx @@ -13,7 +13,7 @@ import loadShoutsQuery from '~/graphql/query/core/articles-load-by' import getAuthorFollowersQuery from '~/graphql/query/core/author-followers' import getAuthorFollowsQuery from '~/graphql/query/core/author-follows' import type { Author, Reaction, Shout, Topic } from '~/graphql/schema/core.gen' -import { byCreated } from '~/lib/sortBy' +import { byCreated } from '~/lib/sort' import { paginate } from '~/utils/paginate' import { restoreScrollPosition, saveScrollPosition } from '~/utils/scroll' import stylesArticle from '../../Article/Article.module.scss' diff --git a/src/components/Views/Feed/Feed.tsx b/src/components/Views/Feed/Feed.tsx index 1cc0ca38..f9cf16ef 100644 --- a/src/components/Views/Feed/Feed.tsx +++ b/src/components/Views/Feed/Feed.tsx @@ -16,7 +16,7 @@ import { useTopics } from '~/context/topics' import { useUI } from '~/context/ui' import { loadUnratedShouts } from '~/graphql/api/private' import type { Author, Reaction, Shout } from '~/graphql/schema/core.gen' -import { byCreated } from '~/lib/sortBy' +import { byCreated } from '~/lib/sort' import { FeedSearchParams } from '~/routes/feed/(feed)' import { CommentDate } from '../../Article/CommentDate' import { getShareUrl } from '../../Article/SharePopup' diff --git a/src/context/authors.tsx b/src/context/authors.tsx index 8b0f1546..4f3d977c 100644 --- a/src/context/authors.tsx +++ b/src/context/authors.tsx @@ -17,7 +17,7 @@ import { Shout, Topic } from '~/graphql/schema/core.gen' -import { byStat } from '~/lib/sortBy' +import { byStat } from '~/lib/sort' import { useFeed } from './feed' const TOP_AUTHORS_COUNT = 5 diff --git a/src/context/feed.tsx b/src/context/feed.tsx index 0fdaa6b6..0c094995 100644 --- a/src/context/feed.tsx +++ b/src/context/feed.tsx @@ -10,7 +10,7 @@ import { Shout, Topic } from '~/graphql/schema/core.gen' -import { byStat } from '../lib/sortBy' +import { byStat } from '../lib/sort' import { useGraphQL } from './graphql' export const PRERENDERED_ARTICLES_COUNT = 5 diff --git a/src/context/topics.tsx b/src/context/topics.tsx index b97e0cd8..6a39e44d 100644 --- a/src/context/topics.tsx +++ b/src/context/topics.tsx @@ -13,7 +13,7 @@ import { import { loadTopics } from '~/graphql/api/public' import { Topic } from '~/graphql/schema/core.gen' import { getRandomTopicsFromArray } from '~/lib/getRandomTopicsFromArray' -import { byTopicStatDesc } from '../lib/sortBy' +import { byTopicStatDesc } from '../lib/sort' type TopicsContextType = { topicEntities: Accessor<{ [topicSlug: string]: Topic }> diff --git a/src/lib/sortby.ts b/src/lib/sort.ts similarity index 85% rename from src/lib/sortby.ts rename to src/lib/sort.ts index ed937c4f..d04bee34 100644 --- a/src/lib/sortby.ts +++ b/src/lib/sort.ts @@ -57,10 +57,3 @@ export const byScore = () => { return 0 } } -// biome-ignore lint/suspicious/noExplicitAny: sort -export const sortBy = (data: any, metric: string | ((a: any, b: any) => number) | undefined) => { - const x = [...data] - // @ts-ignore - x.sort(typeof metric === 'function' ? metric : byStat(metric)) - return x -} diff --git a/src/routes/(main).tsx b/src/routes/(main).tsx index e3f589a3..acfb46d2 100644 --- a/src/routes/(main).tsx +++ b/src/routes/(main).tsx @@ -3,7 +3,7 @@ import { Show, Suspense, createEffect, createSignal, onMount } from 'solid-js' import { useTopics } from '~/context/topics' import { loadShouts, loadTopics } from '~/graphql/api/public' import { LoadShoutsOptions, Shout } from '~/graphql/schema/core.gen' -import { byStat } from '~/lib/sortBy' +import { byStat } from '~/lib/sort' import { restoreScrollPosition, saveScrollPosition } from '~/utils/scroll' import { HomeView, HomeViewProps } from '../components/Views/Home' import { Loading } from '../components/_shared/Loading'