This commit is contained in:
Igor Lobanov 2022-11-22 04:02:11 +01:00
parent 4b50de13a7
commit ff04a63ebc
6 changed files with 11 additions and 10 deletions

View File

@ -1,4 +1,4 @@
import { HomeView, PRERENDERED_ARTICLES_COUNT } from '../Views/Home'
import { HomeView, PRERENDERED_ARTICLES_COUNT, RANDOM_TOPICS_COUNT } from '../Views/Home'
import { PageWrap } from '../_shared/PageWrap'
import type { PageProps } from '../types'
import { createSignal, onCleanup, onMount, Show } from 'solid-js'
@ -15,8 +15,8 @@ export const HomePage = (props: PageProps) => {
return
}
await loadShouts({ filters: { visibility: 'public' }, limit: PRERENDERED_ARTICLES_COUNT, offset: 0 })
await loadRandomTopics()
await loadShouts({ filters: { visibility: 'public' }, limit: PRERENDERED_ARTICLES_COUNT })
await loadRandomTopics({ amount: RANDOM_TOPICS_COUNT })
setIsLoaded(true)
})

View File

@ -25,6 +25,7 @@ type HomeProps = {
}
export const PRERENDERED_ARTICLES_COUNT = 5
export const RANDOM_TOPICS_COUNT = 12
const CLIENT_LOAD_ARTICLES_COUNT = 29
const LOAD_MORE_PAGE_SIZE = 16 // Row1 + Row3 + Row2 + Beside (3 + 1) + Row1 + Row 2 + Row3

View File

@ -32,7 +32,7 @@ const options: ClientOptions = {
// меняем через setToken, например при получении значения с сервера
// скорее всего придумаем что-нибудь получше со временем
const token = localStorage.getItem(TOKEN_LOCAL_STORAGE_KEY)
const headers = { Auth: token }
const headers = { Authorization: token }
return { headers }
},
exchanges

View File

@ -32,8 +32,8 @@ export default gql`
createdAt
publishedAt
stat {
_id: viewed
viewed
# _id: viewed
# viewed
reacted
rating
}

View File

@ -3,9 +3,9 @@ import Prerendered from '../main.astro'
import { Root } from '../components/Root'
import { apiClient } from '../utils/apiClient'
import { initRouter } from '../stores/router'
import { PRERENDERED_ARTICLES_COUNT } from '../components/Views/Home'
import { PRERENDERED_ARTICLES_COUNT, RANDOM_TOPICS_COUNT } from '../components/Views/Home'
const randomTopics = await apiClient.getRandomTopics({ amount: 12 })
const randomTopics = await apiClient.getRandomTopics({ amount: RANDOM_TOPICS_COUNT })
const articles = await apiClient.getShouts(
{ filters: { visibility: "public" }, limit: PRERENDERED_ARTICLES_COUNT })

View File

@ -94,8 +94,8 @@ export const loadAllTopics = async (): Promise<void> => {
addTopics(topics)
}
export const loadRandomTopics = async (): Promise<void> => {
const topics = await apiClient.getRandomTopics({ amount: 12 })
export const loadRandomTopics = async ({ amount }: { amount: number }): Promise<void> => {
const topics = await apiClient.getRandomTopics({ amount })
setRandomTopics(topics)
}