diff --git a/src/components/Views/Home.tsx b/src/components/Views/Home.tsx index e7bbdbc1..b790385c 100644 --- a/src/components/Views/Home.tsx +++ b/src/components/Views/Home.tsx @@ -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 { getPagePath } from '@nanostores/router' import { batch, createMemo, createSignal, For, onMount, Show } from 'solid-js' @@ -15,7 +12,6 @@ import { } from '../../stores/zine/articles' import { useTopAuthorsStore } from '../../stores/zine/topAuthors' import { useTopicsStore } from '../../stores/zine/topics' -import { apiClient } from '../../utils/apiClient' import { restoreScrollPosition, saveScrollPosition } from '../../utils/scroll' import { splitToPages } from '../../utils/splitToPages' import { Icon } from '../_shared/Icon' @@ -32,6 +28,7 @@ import RowShort from '../Feed/RowShort' import { Topics } from '../Nav/Topics' import styles from './Home.module.scss' +import { apiClient } from '../../graphql/client/core' type Props = { shouts: Shout[] diff --git a/src/graphql/client/core.ts b/src/graphql/client/core.ts index 1c7ead48..e4432004 100644 --- a/src/graphql/client/core.ts +++ b/src/graphql/client/core.ts @@ -43,6 +43,7 @@ import topicBySlug from '../query/core/topic-by-slug' import topicsAll from '../query/core/topics-all' import userFollowedTopics from '../query/core/topics-by-author' import topicsRandomQuery from '../query/core/topics-random' +import articlesLoadRandomTopic from '../query/core/articles-load-random-topic' const publicGraphQLClient = createGraphQLClient('core') @@ -78,6 +79,16 @@ export const apiClient = { 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 }) => { const response = await apiClient.private.mutation(followMutation, { what, slug }).toPromise() return response.data.follow diff --git a/src/graphql/query/articles-load-random-topic.ts b/src/graphql/query/core/articles-load-random-topic.ts similarity index 85% rename from src/graphql/query/articles-load-random-topic.ts rename to src/graphql/query/core/articles-load-random-topic.ts index b6bc8a39..5ae25c19 100644 --- a/src/graphql/query/articles-load-random-topic.ts +++ b/src/graphql/query/core/articles-load-random-topic.ts @@ -2,7 +2,7 @@ import { gql } from '@urql/core' export default gql` query LoadRandomTopicShoutsQuery($limit: Int!) { - loadRandomTopicShouts(limit: $limit) { + load_shouts_random_topic(limit: $limit) { topic { id title @@ -28,7 +28,7 @@ export default gql` cover lead # community - mainTopic + main_topic topics { id title @@ -44,12 +44,12 @@ export default gql` id name slug - userpic - createdAt + pic + created_at bio } - createdAt - publishedAt + created_at + published_at stat { viewed reacted diff --git a/src/pages/allAuthors.page.tsx b/src/pages/allAuthors.page.tsx index 0384eb7c..5b4b4f99 100644 --- a/src/pages/allAuthors.page.tsx +++ b/src/pages/allAuthors.page.tsx @@ -17,7 +17,7 @@ export const AllAuthorsPage = (props: PageProps) => { return } - await loadAllAuthors() + await loadAllAuthors() // default limit, offset: 60, 0 setIsLoaded(true) }) diff --git a/src/stores/zine/authors.ts b/src/stores/zine/authors.ts index 20a44f24..fdade0b9 100644 --- a/src/stores/zine/authors.ts +++ b/src/stores/zine/authors.ts @@ -83,8 +83,8 @@ export const addAuthorsByTopic = (newAuthorsByTopic: { [topicSlug: string]: Auth }) } -export const loadAllAuthors = async (): Promise => { - const authors = await apiClient.getAllAuthors() +export const loadAllAuthors = async (limit: number = 50, offset = 0): Promise => { + const authors = await apiClient.getAllAuthors(limit, offset) addAuthors(authors) }