prepare-all-authors
This commit is contained in:
parent
0adeba1407
commit
62887f88c0
|
@ -1,6 +1,3 @@
|
||||||
import { createMemo, createSignal, For, onMount, Show } from 'solid-js'
|
|
||||||
|
|
||||||
import { useLocalize } from '../../context/localize'
|
|
||||||
import { Shout, Topic } from '../../graphql/schema/core.gen'
|
import { Shout, Topic } from '../../graphql/schema/core.gen'
|
||||||
import { getPagePath } from '@nanostores/router'
|
import { getPagePath } from '@nanostores/router'
|
||||||
import { batch, createMemo, createSignal, For, onMount, Show } from 'solid-js'
|
import { batch, createMemo, createSignal, For, onMount, Show } from 'solid-js'
|
||||||
|
@ -15,7 +12,6 @@ import {
|
||||||
} from '../../stores/zine/articles'
|
} from '../../stores/zine/articles'
|
||||||
import { useTopAuthorsStore } from '../../stores/zine/topAuthors'
|
import { useTopAuthorsStore } from '../../stores/zine/topAuthors'
|
||||||
import { useTopicsStore } from '../../stores/zine/topics'
|
import { useTopicsStore } from '../../stores/zine/topics'
|
||||||
import { apiClient } from '../../utils/apiClient'
|
|
||||||
import { restoreScrollPosition, saveScrollPosition } from '../../utils/scroll'
|
import { restoreScrollPosition, saveScrollPosition } from '../../utils/scroll'
|
||||||
import { splitToPages } from '../../utils/splitToPages'
|
import { splitToPages } from '../../utils/splitToPages'
|
||||||
import { Icon } from '../_shared/Icon'
|
import { Icon } from '../_shared/Icon'
|
||||||
|
@ -32,6 +28,7 @@ import RowShort from '../Feed/RowShort'
|
||||||
import { Topics } from '../Nav/Topics'
|
import { Topics } from '../Nav/Topics'
|
||||||
|
|
||||||
import styles from './Home.module.scss'
|
import styles from './Home.module.scss'
|
||||||
|
import { apiClient } from '../../graphql/client/core'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
shouts: Shout[]
|
shouts: Shout[]
|
||||||
|
|
|
@ -43,6 +43,7 @@ import topicBySlug from '../query/core/topic-by-slug'
|
||||||
import topicsAll from '../query/core/topics-all'
|
import topicsAll from '../query/core/topics-all'
|
||||||
import userFollowedTopics from '../query/core/topics-by-author'
|
import userFollowedTopics from '../query/core/topics-by-author'
|
||||||
import topicsRandomQuery from '../query/core/topics-random'
|
import topicsRandomQuery from '../query/core/topics-random'
|
||||||
|
import articlesLoadRandomTopic from '../query/core/articles-load-random-topic'
|
||||||
|
|
||||||
const publicGraphQLClient = createGraphQLClient('core')
|
const publicGraphQLClient = createGraphQLClient('core')
|
||||||
|
|
||||||
|
@ -78,6 +79,16 @@ export const apiClient = {
|
||||||
return response.data.get_topics_random
|
return response.data.get_topics_random
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getRandomTopicShouts: async (limit: number): Promise<{ topic: Topic; shouts: Shout[] }> => {
|
||||||
|
const resp = await publicGraphQLClient.query(articlesLoadRandomTopic, { limit }).toPromise()
|
||||||
|
|
||||||
|
if (resp.error) {
|
||||||
|
console.error(resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp.data.load_random_topics_shouts
|
||||||
|
},
|
||||||
|
|
||||||
follow: async ({ what, slug }: { what: FollowingEntity; slug: string }) => {
|
follow: async ({ what, slug }: { what: FollowingEntity; slug: string }) => {
|
||||||
const response = await apiClient.private.mutation(followMutation, { what, slug }).toPromise()
|
const response = await apiClient.private.mutation(followMutation, { what, slug }).toPromise()
|
||||||
return response.data.follow
|
return response.data.follow
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { gql } from '@urql/core'
|
||||||
|
|
||||||
export default gql`
|
export default gql`
|
||||||
query LoadRandomTopicShoutsQuery($limit: Int!) {
|
query LoadRandomTopicShoutsQuery($limit: Int!) {
|
||||||
loadRandomTopicShouts(limit: $limit) {
|
load_shouts_random_topic(limit: $limit) {
|
||||||
topic {
|
topic {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
|
@ -28,7 +28,7 @@ export default gql`
|
||||||
cover
|
cover
|
||||||
lead
|
lead
|
||||||
# community
|
# community
|
||||||
mainTopic
|
main_topic
|
||||||
topics {
|
topics {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
|
@ -44,12 +44,12 @@ export default gql`
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
slug
|
slug
|
||||||
userpic
|
pic
|
||||||
createdAt
|
created_at
|
||||||
bio
|
bio
|
||||||
}
|
}
|
||||||
createdAt
|
created_at
|
||||||
publishedAt
|
published_at
|
||||||
stat {
|
stat {
|
||||||
viewed
|
viewed
|
||||||
reacted
|
reacted
|
|
@ -17,7 +17,7 @@ export const AllAuthorsPage = (props: PageProps) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await loadAllAuthors()
|
await loadAllAuthors() // default limit, offset: 60, 0
|
||||||
setIsLoaded(true)
|
setIsLoaded(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,8 @@ export const addAuthorsByTopic = (newAuthorsByTopic: { [topicSlug: string]: Auth
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadAllAuthors = async (): Promise<void> => {
|
export const loadAllAuthors = async (limit: number = 50, offset = 0): Promise<void> => {
|
||||||
const authors = await apiClient.getAllAuthors()
|
const authors = await apiClient.getAllAuthors(limit, offset)
|
||||||
addAuthors(authors)
|
addAuthors(authors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user