merged.
This commit is contained in:
parent
25aaecf360
commit
57baccccf2
|
@ -130,8 +130,8 @@ export const AuthorView = (props: Props) => {
|
|||
}
|
||||
})
|
||||
|
||||
const ogImage = props.author?.userpic
|
||||
? getImageUrl(props.author.userpic, { width: 1200 })
|
||||
const ogImage = props.author?.pic
|
||||
? getImageUrl(props.author.pic, { width: 1200 })
|
||||
: getImageUrl('production/image/logo_image.png')
|
||||
const description = getDescription(props.author?.bio)
|
||||
const ogTitle = props.author?.name
|
||||
|
|
|
@ -3,17 +3,12 @@ import { clsx } from 'clsx'
|
|||
import { createEffect, createMemo, createSignal, For, on, onCleanup, onMount, Show } from 'solid-js'
|
||||
|
||||
import { useLocalize } from '../../../context/localize'
|
||||
import {
|
||||
LoadRandomTopShoutsParams,
|
||||
LoadShoutsFilters,
|
||||
LoadShoutsOptions,
|
||||
Shout,
|
||||
} from '../../../graphql/schema/core.gen'
|
||||
import { apiClient } from '../../../graphql/client/core'
|
||||
import { LoadShoutsFilters, LoadShoutsOptions, Shout } from '../../../graphql/schema/core.gen'
|
||||
import { LayoutType } from '../../../pages/types'
|
||||
import { router } from '../../../stores/router'
|
||||
import { loadShouts, resetSortedArticles, useArticlesStore } from '../../../stores/zine/articles'
|
||||
import { apiClient } from '../../../utils/apiClient'
|
||||
import { getServerDate } from '../../../utils/getServerDate'
|
||||
import { getUnixtime } from '../../../utils/getServerDate'
|
||||
import { restoreScrollPosition, saveScrollPosition } from '../../../utils/scroll'
|
||||
import { splitToPages } from '../../../utils/splitToPages'
|
||||
import { Button } from '../../_shared/Button'
|
||||
|
@ -48,10 +43,11 @@ export const Expo = (props: Props) => {
|
|||
const getLoadShoutsFilters = (filters: LoadShoutsFilters = {}): LoadShoutsFilters => {
|
||||
const result = { ...filters }
|
||||
|
||||
filters.layouts = []
|
||||
if (props.layout) {
|
||||
filters.layout = props.layout
|
||||
filters.layouts.push(props.layout)
|
||||
} else {
|
||||
filters.excludeLayout = 'article'
|
||||
filters.layouts.push('article')
|
||||
}
|
||||
|
||||
return result
|
||||
|
@ -64,8 +60,8 @@ export const Expo = (props: Props) => {
|
|||
offset: sortedArticles().length,
|
||||
}
|
||||
|
||||
options.filters = getLayout()
|
||||
? { layouts: [getLayout()] }
|
||||
options.filters = props.layout
|
||||
? { layouts: [props.layout] }
|
||||
: { layouts: ['audio', 'video', 'image', 'literature'] }
|
||||
|
||||
const { hasMore } = await loadShouts(options)
|
||||
|
@ -79,27 +75,27 @@ export const Expo = (props: Props) => {
|
|||
}
|
||||
|
||||
const loadRandomTopArticles = async () => {
|
||||
const params: LoadRandomTopShoutsParams = {
|
||||
const options: LoadShoutsOptions = {
|
||||
filters: getLoadShoutsFilters(),
|
||||
limit: 10,
|
||||
fromRandomCount: 100,
|
||||
random_limit: 100,
|
||||
}
|
||||
|
||||
const result = await apiClient.getRandomTopShouts(params)
|
||||
const result = await apiClient.getRandomTopShouts({ options })
|
||||
setRandomTopArticles(result)
|
||||
}
|
||||
|
||||
const loadRandomTopMonthArticles = async () => {
|
||||
const now = new Date()
|
||||
const fromDate = getServerDate(new Date(now.setMonth(now.getMonth() - 1)))
|
||||
const after = getUnixtime(new Date(now.setMonth(now.getMonth() - 1)))
|
||||
|
||||
const params: LoadRandomTopShoutsParams = {
|
||||
filters: getLoadShoutsFilters({ fromDate }),
|
||||
const options: LoadShoutsOptions = {
|
||||
filters: getLoadShoutsFilters({ after }),
|
||||
limit: 10,
|
||||
fromRandomCount: 10,
|
||||
random_limit: 10,
|
||||
}
|
||||
|
||||
const result = await apiClient.getRandomTopShouts(params)
|
||||
const result = await apiClient.getRandomTopShouts({ options })
|
||||
setRandomTopMonthArticles(result)
|
||||
}
|
||||
|
||||
|
@ -171,11 +167,11 @@ export const Expo = (props: Props) => {
|
|||
<span class={clsx('linkReplacement')}>{t('Literature')}</span>
|
||||
</ConditionalWrapper>
|
||||
</li>
|
||||
<li class={clsx({ 'view-switcher__item--selected': getLayout() === 'audio' })}>
|
||||
<li class={clsx({ 'view-switcher__item--selected': props.layout === 'audio' })}>
|
||||
<ConditionalWrapper
|
||||
condition={getLayout() !== 'audio'}
|
||||
condition={props.layout !== 'audio'}
|
||||
wrapper={(children) => (
|
||||
<a href={getPagePath(router, 'expoLayout', { layout: 'audio' })}>{children}</a>
|
||||
<a href={getPagePath(router, 'expo', { layout: 'audio' })}>{children}</a>
|
||||
)}
|
||||
>
|
||||
<span class={clsx('linkReplacement')}>{t('Music')}</span>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { Author, LoadShoutsOptions, Reaction, Shout } from '../../graphql/schema/core.gen'
|
||||
import type { Author, LoadShoutsOptions, Reaction, Shout } from '../../../graphql/schema/core.gen'
|
||||
|
||||
import { getPagePath } from '@nanostores/router'
|
||||
import { Meta } from '@solidjs/meta'
|
||||
|
@ -7,11 +7,11 @@ import { createEffect, createSignal, For, on, onMount, Show } from 'solid-js'
|
|||
|
||||
import { useLocalize } from '../../../context/localize'
|
||||
import { useReactions } from '../../../context/reactions'
|
||||
import { apiClient } from '../../../graphql/client/core'
|
||||
import { router, useRouter } from '../../../stores/router'
|
||||
import { useArticlesStore, resetSortedArticles } from '../../../stores/zine/articles'
|
||||
import { useTopAuthorsStore } from '../../../stores/zine/topAuthors'
|
||||
import { useTopicsStore } from '../../../stores/zine/topics'
|
||||
import { apiClient } from '../../../utils/apiClient'
|
||||
import { getImageUrl } from '../../../utils/getImageUrl'
|
||||
import { Icon } from '../../_shared/Icon'
|
||||
import { Loading } from '../../_shared/Loading'
|
||||
|
|
|
@ -1 +1 @@
|
|||
export { Feed } from './Feed'
|
||||
export { FeedView as Feed } from './Feed'
|
||||
|
|
|
@ -11,6 +11,7 @@ import type {
|
|||
Result,
|
||||
QueryLoad_Authors_ByArgs,
|
||||
QueryLoad_Shouts_SearchArgs,
|
||||
QueryLoad_Shouts_Random_TopArgs,
|
||||
} from '../schema/core.gen'
|
||||
|
||||
import { createGraphQLClient } from '../createGraphQLClient'
|
||||
|
@ -27,7 +28,9 @@ import shoutLoad from '../query/core/article-load'
|
|||
import shoutsLoadBy from '../query/core/articles-load-by'
|
||||
import draftsLoad from '../query/core/articles-load-drafts'
|
||||
import myFeed from '../query/core/articles-load-feed'
|
||||
import loadShoutsTopRandom from '../query/core/articles-load-random-top'
|
||||
import shoutsLoadSearch from '../query/core/articles-load-search'
|
||||
import loadShoutsUnrated from '../query/core/articles-load-unrated'
|
||||
import authorBy from '../query/core/author-by'
|
||||
import authorFollowers from '../query/core/author-followers'
|
||||
import authorId from '../query/core/author-id'
|
||||
|
@ -47,6 +50,24 @@ export const apiClient = {
|
|||
private: null,
|
||||
connect: (token: string) => (apiClient.private = createGraphQLClient('core', token)), // NOTE: use it after token appears
|
||||
|
||||
getRandomTopShouts: async (params: QueryLoad_Shouts_Random_TopArgs) => {
|
||||
const response = await publicGraphQLClient.query(loadShoutsTopRandom, params).toPromise()
|
||||
if (!response.data) {
|
||||
console.error('[graphql.core] getRandomTopShouts error', response.error)
|
||||
}
|
||||
return response.data.load_shouts_top_random
|
||||
},
|
||||
|
||||
getUnratedShouts: async (limit = 50, offset = 0) => {
|
||||
const response = await apiClient.private.query(loadShoutsUnrated, { limit, offset }).toPromise()
|
||||
|
||||
if (!response.data) {
|
||||
console.error('[graphql.core] getUnratedShouts error', response.error)
|
||||
}
|
||||
|
||||
return response.data.load_shouts_unrated
|
||||
},
|
||||
|
||||
getRandomTopics: async ({ amount }: { amount: number }) => {
|
||||
const response = await publicGraphQLClient.query(topicsRandomQuery, { amount }).toPromise()
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ export default gql`
|
|||
layout
|
||||
slug
|
||||
cover
|
||||
# community
|
||||
# cover_caption
|
||||
main_topic
|
||||
topics {
|
||||
# id
|
||||
|
|
|
@ -2,18 +2,17 @@ import { gql } from '@urql/core'
|
|||
|
||||
export default gql`
|
||||
query LoadRandomTopShoutsQuery($params: LoadRandomTopShoutsParams) {
|
||||
loadRandomTopShouts(params: $params) {
|
||||
load_shouts_top_random(params: $params) {
|
||||
id
|
||||
title
|
||||
lead
|
||||
# lead
|
||||
description
|
||||
subtitle
|
||||
slug
|
||||
layout
|
||||
cover
|
||||
lead
|
||||
# community
|
||||
mainTopic
|
||||
cover_caption
|
||||
main_topic
|
||||
topics {
|
||||
id
|
||||
title
|
||||
|
@ -29,12 +28,12 @@ export default gql`
|
|||
id
|
||||
name
|
||||
slug
|
||||
userpic
|
||||
createdAt
|
||||
pic
|
||||
created_at
|
||||
bio
|
||||
}
|
||||
createdAt
|
||||
publishedAt
|
||||
created_at
|
||||
published_at
|
||||
stat {
|
||||
viewed
|
||||
reacted
|
|
@ -5,15 +5,15 @@ export default gql`
|
|||
loadUnratedShouts(limit: $limit) {
|
||||
id
|
||||
title
|
||||
lead
|
||||
# lead
|
||||
description
|
||||
subtitle
|
||||
slug
|
||||
layout
|
||||
cover
|
||||
lead
|
||||
cover_caption
|
||||
# community
|
||||
mainTopic
|
||||
main_topic
|
||||
topics {
|
||||
id
|
||||
title
|
||||
|
@ -29,12 +29,12 @@ export default gql`
|
|||
id
|
||||
name
|
||||
slug
|
||||
userpic
|
||||
createdAt
|
||||
pic
|
||||
created_at
|
||||
bio
|
||||
}
|
||||
createdAt
|
||||
publishedAt
|
||||
created_at
|
||||
published_at
|
||||
stat {
|
||||
viewed
|
||||
reacted
|
|
@ -2,3 +2,7 @@ export const getServerDate = (date: Date): string => {
|
|||
// 2023-12-31
|
||||
return date.toISOString().slice(0, 10)
|
||||
}
|
||||
|
||||
export const getUnixtime = (date: Date): number => {
|
||||
return Math.floor(date.getTime() / 1000)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Shout } from '../graphql/types.gen'
|
||||
import { Shout } from '../graphql/schema/core.gen'
|
||||
|
||||
const MAX_DESCRIPTION_LENGTH = 150
|
||||
export const getDescription = (body: string): string => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user