sortfn-type
This commit is contained in:
parent
4efec31fec
commit
2b7a825bc5
|
@ -1,19 +1,17 @@
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import { For, Show, createMemo, createSignal, lazy, onMount } from 'solid-js'
|
import { For, Show, createMemo, createSignal, lazy, onMount } from 'solid-js'
|
||||||
|
|
||||||
|
import { useFeed } from '~/context/feed'
|
||||||
import { useLocalize } from '~/context/localize'
|
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/sort'
|
import { byCreated, byStat } from '~/lib/sort'
|
||||||
|
import { SortFunction } from '~/types/common'
|
||||||
import { Button } from '../_shared/Button'
|
import { Button } from '../_shared/Button'
|
||||||
import { ShowIfAuthenticated } from '../_shared/ShowIfAuthenticated'
|
import { ShowIfAuthenticated } from '../_shared/ShowIfAuthenticated'
|
||||||
|
|
||||||
import { Comment } from './Comment'
|
|
||||||
|
|
||||||
import { SortFunction } from '~/context/authors'
|
|
||||||
import { useFeed } from '~/context/feed'
|
|
||||||
import styles from './Article.module.scss'
|
import styles from './Article.module.scss'
|
||||||
|
import { Comment } from './Comment'
|
||||||
|
|
||||||
const SimplifiedEditor = lazy(() => import('../Editor/SimplifiedEditor'))
|
const SimplifiedEditor = lazy(() => import('../Editor/SimplifiedEditor'))
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,11 @@ import {
|
||||||
Topic
|
Topic
|
||||||
} from '~/graphql/schema/core.gen'
|
} from '~/graphql/schema/core.gen'
|
||||||
import { byStat } from '~/lib/sort'
|
import { byStat } from '~/lib/sort'
|
||||||
|
import { FilterFunction, SortFunction } from '~/types/common'
|
||||||
import { useFeed } from './feed'
|
import { useFeed } from './feed'
|
||||||
|
|
||||||
const TOP_AUTHORS_COUNT = 5
|
const TOP_AUTHORS_COUNT = 5
|
||||||
|
|
||||||
type FilterFunction<Author> = (a: Author) => boolean
|
|
||||||
export type SortFunction<Author> = (a: Author, b: Author) => number
|
|
||||||
|
|
||||||
// Универсальная функция фильтрации и сортировки
|
// Универсальная функция фильтрации и сортировки
|
||||||
function filterAndSort<Author>(
|
function filterAndSort<Author>(
|
||||||
items: Author[],
|
items: Author[],
|
||||||
|
|
|
@ -4,6 +4,7 @@ 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/sort'
|
import { byStat } from '~/lib/sort'
|
||||||
|
import { SortFunction } from '~/types/common'
|
||||||
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'
|
||||||
|
@ -11,7 +12,6 @@ import { PageLayout } from '../components/_shared/PageLayout'
|
||||||
import { useLocalize } from '../context/localize'
|
import { useLocalize } from '../context/localize'
|
||||||
|
|
||||||
export const SHOUTS_PER_PAGE = 20
|
export const SHOUTS_PER_PAGE = 20
|
||||||
type SortFunction<Shout> = (a: Shout, b: Shout) => number
|
|
||||||
|
|
||||||
const fetchAllTopics = async () => {
|
const fetchAllTopics = async () => {
|
||||||
const allTopicsLoader = loadTopics()
|
const allTopicsLoader = loadTopics()
|
||||||
|
|
2
src/types/common.d.ts
vendored
2
src/types/common.d.ts
vendored
|
@ -6,3 +6,5 @@ export type RootSearchParams = {
|
||||||
|
|
||||||
export type LayoutType = 'article' | 'audio' | 'video' | 'image' | 'literature';
|
export type LayoutType = 'article' | 'audio' | 'video' | 'image' | 'literature';
|
||||||
export type FollowsFilter = 'all' | 'authors' | 'topics' | 'communities';
|
export type FollowsFilter = 'all' | 'authors' | 'topics' | 'communities';
|
||||||
|
export type SortFunction<T> = (a: T, b: T) => number
|
||||||
|
export type FilterFunction<T> = (a: T) => boolean
|
||||||
|
|
Loading…
Reference in New Issue
Block a user