fixed
This commit is contained in:
parent
deebe79f55
commit
423af46377
|
@ -23,6 +23,8 @@ type AllAuthorsPageSearchParams = {
|
|||
|
||||
type Props = {
|
||||
authors: Author[]
|
||||
topFollowedAuthors?: Author[]
|
||||
topWritingAuthors?: Author[]
|
||||
isLoaded: boolean
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ type Props = {
|
|||
isLoaded: boolean
|
||||
}
|
||||
|
||||
const PAGE_SIZE = 20
|
||||
export const PAGE_SIZE = 20
|
||||
|
||||
export const AllTopics = (props: Props) => {
|
||||
const { t, lang } = useLocalize()
|
||||
|
|
|
@ -48,23 +48,11 @@ type VisibilityItem = {
|
|||
}
|
||||
|
||||
type FeedSearchParams = {
|
||||
by: 'publish_date' | 'likes_stat' | 'rating' | 'last_comment'
|
||||
by: 'publish_date' | 'likes' | 'comments'
|
||||
period: FeedPeriod
|
||||
visibility: VisibilityMode
|
||||
}
|
||||
|
||||
const getOrderBy = (by: FeedSearchParams['by']) => {
|
||||
if (by === 'likes_stat' || by === 'rating') {
|
||||
return 'likes_stat'
|
||||
}
|
||||
|
||||
if (by === 'last_comment') {
|
||||
return 'last_comment'
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
const getFromDate = (period: FeedPeriod): number => {
|
||||
const now = new Date()
|
||||
let d: Date = now
|
||||
|
@ -178,9 +166,8 @@ export const FeedView = (props: Props) => {
|
|||
offset: sortedArticles().length,
|
||||
}
|
||||
|
||||
const orderBy = getOrderBy(searchParams().by)
|
||||
if (orderBy) {
|
||||
options.order_by = orderBy
|
||||
if (searchParams()?.by) {
|
||||
options.order_by = searchParams().by
|
||||
}
|
||||
|
||||
const visibilityMode = searchParams().visibility
|
||||
|
@ -222,7 +209,7 @@ export const FeedView = (props: Props) => {
|
|||
const ogTitle = t('Feed')
|
||||
|
||||
const [shareData, setShareData] = createSignal<Shout | undefined>()
|
||||
const handleShare = (shared) => {
|
||||
const handleShare = (shared: Shout | undefined) => {
|
||||
showModal('share')
|
||||
setShareData(shared)
|
||||
}
|
||||
|
@ -260,19 +247,19 @@ export const FeedView = (props: Props) => {
|
|||
{/*</li>*/}
|
||||
<li
|
||||
class={clsx({
|
||||
'view-switcher__item--selected': searchParams().by === 'rating',
|
||||
'view-switcher__item--selected': searchParams().by === 'likes',
|
||||
})}
|
||||
>
|
||||
<span class="link" onClick={() => changeSearchParams({ by: 'rating' })}>
|
||||
<span class="link" onClick={() => changeSearchParams({ by: 'likes' })}>
|
||||
{t('Top rated')}
|
||||
</span>
|
||||
</li>
|
||||
<li
|
||||
class={clsx({
|
||||
'view-switcher__item--selected': searchParams().by === 'last_comment',
|
||||
'view-switcher__item--selected': searchParams().by === 'comments',
|
||||
})}
|
||||
>
|
||||
<span class="link" onClick={() => changeSearchParams({ by: 'last_comment' })}>
|
||||
<span class="link" onClick={() => changeSearchParams({ by: 'comments' })}>
|
||||
{t('Most commented')}
|
||||
</span>
|
||||
</li>
|
||||
|
|
|
@ -2,11 +2,13 @@ import type { PageContext } from '../renderer/types'
|
|||
import type { PageProps } from './types'
|
||||
|
||||
import { apiClient } from '../graphql/client/core'
|
||||
import { PAGE_SIZE } from "../components/Views/AllTopics/AllTopics";
|
||||
|
||||
export const onBeforeRender = async (_pageContext: PageContext) => {
|
||||
const allAuthors = await apiClient.getAllAuthors()
|
||||
|
||||
const pageProps: PageProps = { allAuthors, seo: { title: '' } }
|
||||
const topWritingAuthors = await apiClient.loadAuthorsBy({ by: { order: 'shouts' }, limit: PAGE_SIZE})
|
||||
const topFollowedAuthors = await apiClient.loadAuthorsBy({ by: { order: 'followers' }, limit: PAGE_SIZE})
|
||||
const pageProps: PageProps = { allAuthors, seo: { title: '' }, topWritingAuthors, topFollowedAuthors }
|
||||
|
||||
return {
|
||||
pageContext: {
|
||||
|
|
|
@ -10,6 +10,8 @@ export type PageProps = {
|
|||
homeShouts?: Shout[]
|
||||
author?: Author
|
||||
allAuthors?: Author[]
|
||||
topWritingAuthors?: Author[]
|
||||
topFollowedAuthors?: Author[]
|
||||
topic?: Topic
|
||||
allTopics?: Topic[]
|
||||
searchQuery?: string
|
||||
|
|
Loading…
Reference in New Issue
Block a user