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