sort
This commit is contained in:
parent
2d7fbc42a8
commit
7c9c155f5b
|
@ -5,7 +5,7 @@ import { useLocalize } from '~/context/localize'
|
||||||
import { useReactions } from '~/context/reactions'
|
import { useReactions } from '~/context/reactions'
|
||||||
import { useSession } from '~/context/session'
|
import { useSession } from '~/context/session'
|
||||||
import { Author, Reaction, ReactionKind, ReactionSort } from '~/graphql/schema/core.gen'
|
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 { Button } from '../_shared/Button'
|
||||||
import { ShowIfAuthenticated } from '../_shared/ShowIfAuthenticated'
|
import { ShowIfAuthenticated } from '../_shared/ShowIfAuthenticated'
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { Button } from '~/components/_shared/Button'
|
||||||
import { Icon } from '~/components/_shared/Icon'
|
import { Icon } from '~/components/_shared/Icon'
|
||||||
import { useFeed } from '~/context/feed'
|
import { useFeed } from '~/context/feed'
|
||||||
import { useLocalize } from '~/context/localize'
|
import { useLocalize } from '~/context/localize'
|
||||||
import { byScore } from '~/lib/sortBy'
|
import { byScore } from '~/lib/sort'
|
||||||
import { restoreScrollPosition, saveScrollPosition } from '~/utils/scroll'
|
import { restoreScrollPosition, saveScrollPosition } from '~/utils/scroll'
|
||||||
import { FEED_PAGE_SIZE } from '../../Views/Feed/Feed'
|
import { FEED_PAGE_SIZE } from '../../Views/Feed/Feed'
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { useLocalize } from '~/context/localize'
|
||||||
import type { Author } from '~/graphql/schema/core.gen'
|
import type { Author } from '~/graphql/schema/core.gen'
|
||||||
import { authorLetterReduce, translateAuthor } from '~/intl/translate'
|
import { authorLetterReduce, translateAuthor } from '~/intl/translate'
|
||||||
import { dummyFilter } from '~/lib/dummyFilter'
|
import { dummyFilter } from '~/lib/dummyFilter'
|
||||||
import { byFirstChar, byStat } from '~/lib/sortBy'
|
import { byFirstChar, byStat } from '~/lib/sort'
|
||||||
import { scrollHandler } from '~/utils/scroll'
|
import { scrollHandler } from '~/utils/scroll'
|
||||||
import styles from './AllAuthors.module.scss'
|
import styles from './AllAuthors.module.scss'
|
||||||
import stylesAuthorList from './AuthorsList.module.scss'
|
import stylesAuthorList from './AuthorsList.module.scss'
|
||||||
|
|
|
@ -13,7 +13,7 @@ import loadShoutsQuery from '~/graphql/query/core/articles-load-by'
|
||||||
import getAuthorFollowersQuery from '~/graphql/query/core/author-followers'
|
import getAuthorFollowersQuery from '~/graphql/query/core/author-followers'
|
||||||
import getAuthorFollowsQuery from '~/graphql/query/core/author-follows'
|
import getAuthorFollowsQuery from '~/graphql/query/core/author-follows'
|
||||||
import type { Author, Reaction, Shout, Topic } from '~/graphql/schema/core.gen'
|
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 { paginate } from '~/utils/paginate'
|
||||||
import { restoreScrollPosition, saveScrollPosition } from '~/utils/scroll'
|
import { restoreScrollPosition, saveScrollPosition } from '~/utils/scroll'
|
||||||
import stylesArticle from '../../Article/Article.module.scss'
|
import stylesArticle from '../../Article/Article.module.scss'
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { useTopics } from '~/context/topics'
|
||||||
import { useUI } from '~/context/ui'
|
import { useUI } from '~/context/ui'
|
||||||
import { loadUnratedShouts } from '~/graphql/api/private'
|
import { loadUnratedShouts } from '~/graphql/api/private'
|
||||||
import type { Author, Reaction, Shout } from '~/graphql/schema/core.gen'
|
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 { FeedSearchParams } from '~/routes/feed/(feed)'
|
||||||
import { CommentDate } from '../../Article/CommentDate'
|
import { CommentDate } from '../../Article/CommentDate'
|
||||||
import { getShareUrl } from '../../Article/SharePopup'
|
import { getShareUrl } from '../../Article/SharePopup'
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {
|
||||||
Shout,
|
Shout,
|
||||||
Topic
|
Topic
|
||||||
} from '~/graphql/schema/core.gen'
|
} from '~/graphql/schema/core.gen'
|
||||||
import { byStat } from '~/lib/sortBy'
|
import { byStat } from '~/lib/sort'
|
||||||
import { useFeed } from './feed'
|
import { useFeed } from './feed'
|
||||||
|
|
||||||
const TOP_AUTHORS_COUNT = 5
|
const TOP_AUTHORS_COUNT = 5
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
Shout,
|
Shout,
|
||||||
Topic
|
Topic
|
||||||
} from '~/graphql/schema/core.gen'
|
} from '~/graphql/schema/core.gen'
|
||||||
import { byStat } from '../lib/sortBy'
|
import { byStat } from '../lib/sort'
|
||||||
import { useGraphQL } from './graphql'
|
import { useGraphQL } from './graphql'
|
||||||
|
|
||||||
export const PRERENDERED_ARTICLES_COUNT = 5
|
export const PRERENDERED_ARTICLES_COUNT = 5
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
import { loadTopics } from '~/graphql/api/public'
|
import { loadTopics } from '~/graphql/api/public'
|
||||||
import { Topic } from '~/graphql/schema/core.gen'
|
import { Topic } from '~/graphql/schema/core.gen'
|
||||||
import { getRandomTopicsFromArray } from '~/lib/getRandomTopicsFromArray'
|
import { getRandomTopicsFromArray } from '~/lib/getRandomTopicsFromArray'
|
||||||
import { byTopicStatDesc } from '../lib/sortBy'
|
import { byTopicStatDesc } from '../lib/sort'
|
||||||
|
|
||||||
type TopicsContextType = {
|
type TopicsContextType = {
|
||||||
topicEntities: Accessor<{ [topicSlug: string]: Topic }>
|
topicEntities: Accessor<{ [topicSlug: string]: Topic }>
|
||||||
|
|
|
@ -57,10 +57,3 @@ export const byScore = () => {
|
||||||
return 0
|
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
|
|
||||||
}
|
|
|
@ -3,7 +3,7 @@ import { Show, Suspense, createEffect, createSignal, onMount } from 'solid-js'
|
||||||
import { useTopics } from '~/context/topics'
|
import { useTopics } from '~/context/topics'
|
||||||
import { loadShouts, loadTopics } from '~/graphql/api/public'
|
import { loadShouts, loadTopics } from '~/graphql/api/public'
|
||||||
import { LoadShoutsOptions, Shout } from '~/graphql/schema/core.gen'
|
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 { restoreScrollPosition, saveScrollPosition } from '~/utils/scroll'
|
||||||
import { HomeView, HomeViewProps } from '../components/Views/Home'
|
import { HomeView, HomeViewProps } from '../components/Views/Home'
|
||||||
import { Loading } from '../components/_shared/Loading'
|
import { Loading } from '../components/_shared/Loading'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user