filter-format-fix
This commit is contained in:
parent
7bc743d8a7
commit
fce0d7cfc6
|
@ -1,6 +1,7 @@
|
||||||
import { createMemo, createSignal, For, onMount, Show } from 'solid-js'
|
import { createMemo, createSignal, For, onMount, Show } from 'solid-js'
|
||||||
|
|
||||||
import { useLocalize } from '../../context/localize'
|
import { useLocalize } from '../../context/localize'
|
||||||
|
import { Shout } from '../../graphql/schema/core.gen'
|
||||||
import {
|
import {
|
||||||
loadShouts,
|
loadShouts,
|
||||||
loadTopArticles,
|
loadTopArticles,
|
||||||
|
@ -22,7 +23,6 @@ import { Row3 } from '../Feed/Row3'
|
||||||
import { Row5 } from '../Feed/Row5'
|
import { Row5 } from '../Feed/Row5'
|
||||||
import RowShort from '../Feed/RowShort'
|
import RowShort from '../Feed/RowShort'
|
||||||
import { Topics } from '../Nav/Topics'
|
import { Topics } from '../Nav/Topics'
|
||||||
import { Shout } from '../../graphql/schema/core.gen'
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
shouts: Shout[]
|
shouts: Shout[]
|
||||||
|
|
|
@ -3,6 +3,7 @@ import type { Author, Result } from '../graphql/schema/core.gen'
|
||||||
import type { Accessor, JSX, Resource } from 'solid-js'
|
import type { Accessor, JSX, Resource } from 'solid-js'
|
||||||
|
|
||||||
import { VerifyEmailInput, LoginInput, AuthToken, User } from '@authorizerdev/authorizer-js'
|
import { VerifyEmailInput, LoginInput, AuthToken, User } from '@authorizerdev/authorizer-js'
|
||||||
|
import { cookieStorage, createStorage } from '@solid-primitives/storage'
|
||||||
import { createContext, createMemo, createResource, createSignal, onMount, useContext } from 'solid-js'
|
import { createContext, createMemo, createResource, createSignal, onMount, useContext } from 'solid-js'
|
||||||
|
|
||||||
import { apiClient } from '../graphql/client/core'
|
import { apiClient } from '../graphql/client/core'
|
||||||
|
@ -11,7 +12,6 @@ import { showModal } from '../stores/ui'
|
||||||
import { useAuthorizer } from './authorizer'
|
import { useAuthorizer } from './authorizer'
|
||||||
import { useLocalize } from './localize'
|
import { useLocalize } from './localize'
|
||||||
import { useSnackbar } from './snackbar'
|
import { useSnackbar } from './snackbar'
|
||||||
import { cookieStorage, createStorage } from '@solid-primitives/storage'
|
|
||||||
|
|
||||||
export type SessionContextType = {
|
export type SessionContextType = {
|
||||||
session: Resource<AuthToken>
|
session: Resource<AuthToken>
|
||||||
|
|
|
@ -11,7 +11,6 @@ import type {
|
||||||
Result,
|
Result,
|
||||||
QueryLoad_Authors_ByArgs,
|
QueryLoad_Authors_ByArgs,
|
||||||
QueryLoad_Shouts_SearchArgs,
|
QueryLoad_Shouts_SearchArgs,
|
||||||
QueryLoad_Shouts_ByArgs,
|
|
||||||
} from '../schema/core.gen'
|
} from '../schema/core.gen'
|
||||||
|
|
||||||
import createArticle from '../mutation/core/article-create'
|
import createArticle from '../mutation/core/article-create'
|
||||||
|
@ -27,9 +26,9 @@ import { getPrivateClient } from '../privateGraphQLClient'
|
||||||
import { getPublicClient } from '../publicGraphQLClient'
|
import { getPublicClient } from '../publicGraphQLClient'
|
||||||
import shoutLoad from '../query/core/article-load'
|
import shoutLoad from '../query/core/article-load'
|
||||||
import shoutsLoadBy from '../query/core/articles-load-by'
|
import shoutsLoadBy from '../query/core/articles-load-by'
|
||||||
import shoutsLoadSearch from '../query/core/articles-load-search'
|
|
||||||
import draftsLoad from '../query/core/articles-load-drafts'
|
import draftsLoad from '../query/core/articles-load-drafts'
|
||||||
import myFeed from '../query/core/articles-load-feed'
|
import myFeed from '../query/core/articles-load-feed'
|
||||||
|
import shoutsLoadSearch from '../query/core/articles-load-search'
|
||||||
import authorBy from '../query/core/author-by'
|
import authorBy from '../query/core/author-by'
|
||||||
import authorFollowers from '../query/core/author-followers'
|
import authorFollowers from '../query/core/author-followers'
|
||||||
import authorsAll from '../query/core/authors-all'
|
import authorsAll from '../query/core/authors-all'
|
||||||
|
@ -148,61 +147,38 @@ export const apiClient = {
|
||||||
console.debug('[graphql.client.core] updateReaction:', response)
|
console.debug('[graphql.client.core] updateReaction:', response)
|
||||||
return response.data.update_reaction.reaction
|
return response.data.update_reaction.reaction
|
||||||
},
|
},
|
||||||
getAuthorsBy: async (options: QueryLoad_Authors_ByArgs) => {
|
getAuthorsBy: async (args: QueryLoad_Authors_ByArgs) => {
|
||||||
const resp = await publicGraphQLClient.query(authorsLoadBy, options).toPromise()
|
const resp = await publicGraphQLClient.query(authorsLoadBy, args).toPromise()
|
||||||
return resp.data.load_authors_by
|
return resp.data.load_authors_by
|
||||||
},
|
},
|
||||||
getShoutBySlug: async (slug: string) => {
|
getShoutBySlug: async (slug: string) => {
|
||||||
const resp = await publicGraphQLClient
|
const resp = await publicGraphQLClient.query(shoutLoad, { slug }).toPromise()
|
||||||
.query(shoutLoad, {
|
|
||||||
slug,
|
|
||||||
})
|
|
||||||
.toPromise()
|
|
||||||
|
|
||||||
// if (resp.error) {
|
|
||||||
// console.error(resp)
|
|
||||||
// }
|
|
||||||
|
|
||||||
return resp.data.get_shout
|
return resp.data.get_shout
|
||||||
},
|
},
|
||||||
getShoutById: async (shout_id: number) => {
|
getShoutById: async (shout_id: number) => {
|
||||||
const resp = await publicGraphQLClient
|
const resp = await publicGraphQLClient.query(shoutLoad, { shout_id }).toPromise()
|
||||||
.query(shoutLoad, {
|
if (resp.error) console.error(resp)
|
||||||
shout_id,
|
|
||||||
})
|
|
||||||
.toPromise()
|
|
||||||
|
|
||||||
if (resp.error) {
|
|
||||||
console.error(resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
return resp.data.get_shout
|
return resp.data.get_shout
|
||||||
},
|
},
|
||||||
|
|
||||||
getShouts: async (args: QueryLoad_Shouts_ByArgs) => {
|
getShouts: async (options: LoadShoutsOptions) => {
|
||||||
const resp = await publicGraphQLClient.query(shoutsLoadBy, args).toPromise()
|
const resp = await publicGraphQLClient.query(shoutsLoadBy, { options }).toPromise()
|
||||||
if (resp.error) {
|
if (resp.error) console.error(resp)
|
||||||
console.error(resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
return resp.data.load_shouts_by
|
return resp.data.load_shouts_by
|
||||||
},
|
},
|
||||||
|
|
||||||
getShoutsSearch: async (args: QueryLoad_Shouts_SearchArgs) => {
|
getShoutsSearch: async (args: QueryLoad_Shouts_SearchArgs) => {
|
||||||
const resp = await publicGraphQLClient.query(shoutsLoadSearch, args).toPromise()
|
const resp = await publicGraphQLClient.query(shoutsLoadSearch, args).toPromise()
|
||||||
if (resp.error) {
|
if (resp.error) console.error(resp)
|
||||||
console.error(resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
return resp.data.load_shouts_search
|
return resp.data.load_shouts_search
|
||||||
},
|
},
|
||||||
|
|
||||||
getMyFeed: async (args: QueryLoad_Shouts_ByArgs) => {
|
getMyFeed: async (options: LoadShoutsOptions) => {
|
||||||
const resp = await privateGraphQLClient.query(myFeed, args).toPromise()
|
const resp = await privateGraphQLClient.query(myFeed, { options }).toPromise()
|
||||||
|
if (resp.error) console.error(resp)
|
||||||
if (resp.error) {
|
|
||||||
console.error(resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
return resp.data.load_shouts_feed
|
return resp.data.load_shouts_feed
|
||||||
},
|
},
|
||||||
|
@ -215,7 +191,7 @@ export const apiClient = {
|
||||||
},
|
},
|
||||||
getMySubscriptions: async (): Promise<Result> => {
|
getMySubscriptions: async (): Promise<Result> => {
|
||||||
const resp = await privateGraphQLClient.query(mySubscriptions, {}).toPromise()
|
const resp = await privateGraphQLClient.query(mySubscriptions, {}).toPromise()
|
||||||
// console.debug(resp.data)
|
|
||||||
return resp.data.get_my_followed
|
return resp.data.get_my_followed
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,11 @@ export const onBeforeRender = async (pageContext: PageContext) => {
|
||||||
if (!author) {
|
if (!author) {
|
||||||
throw render(404)
|
throw render(404)
|
||||||
}
|
}
|
||||||
const options = {
|
|
||||||
filters: { author: slug, visibility: 'community' },
|
const authorShouts = await apiClient.getShouts({
|
||||||
|
filters: { author: slug, published: false },
|
||||||
limit: PRERENDERED_ARTICLES_COUNT,
|
limit: PRERENDERED_ARTICLES_COUNT,
|
||||||
}
|
})
|
||||||
const authorShouts = await apiClient.getShouts({ options })
|
|
||||||
const pageProps: PageProps = { author, authorShouts, seo: { title: author.name } }
|
const pageProps: PageProps = { author, authorShouts, seo: { title: author.name } }
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -5,11 +5,10 @@ import { PRERENDERED_ARTICLES_COUNT } from '../../components/Views/Expo/Expo'
|
||||||
import { apiClient } from '../../graphql/client/core'
|
import { apiClient } from '../../graphql/client/core'
|
||||||
|
|
||||||
export const onBeforeRender = async (_pageContext: PageContext) => {
|
export const onBeforeRender = async (_pageContext: PageContext) => {
|
||||||
const options = {
|
const expoShouts = await apiClient.getShouts({
|
||||||
filters: { layouts: ['audio', 'video', 'literature', 'image'] },
|
filters: { layouts: ['audio', 'video', 'literature', 'image'] },
|
||||||
limit: PRERENDERED_ARTICLES_COUNT,
|
limit: PRERENDERED_ARTICLES_COUNT,
|
||||||
}
|
})
|
||||||
const expoShouts = await apiClient.getShouts({ options })
|
|
||||||
const pageProps: PageProps = { expoShouts, seo: { title: '' } }
|
const pageProps: PageProps = { expoShouts, seo: { title: '' } }
|
||||||
return {
|
return {
|
||||||
pageContext: {
|
pageContext: {
|
||||||
|
|
|
@ -10,7 +10,7 @@ export const onBeforeRender = async (pageContext: PageContext) => {
|
||||||
filters: { layouts: [layout] },
|
filters: { layouts: [layout] },
|
||||||
limit: PRERENDERED_ARTICLES_COUNT,
|
limit: PRERENDERED_ARTICLES_COUNT,
|
||||||
}
|
}
|
||||||
const expoShouts = await apiClient.getShouts({ options })
|
const expoShouts = await apiClient.getShouts(options)
|
||||||
const pageProps: PageProps = { expoShouts, seo: { title: '' } }
|
const pageProps: PageProps = { expoShouts, seo: { title: '' } }
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -5,11 +5,10 @@ import { PRERENDERED_ARTICLES_COUNT } from '../components/Views/Home'
|
||||||
import { apiClient } from '../graphql/client/core'
|
import { apiClient } from '../graphql/client/core'
|
||||||
|
|
||||||
export const onBeforeRender = async (_pageContext: PageContext) => {
|
export const onBeforeRender = async (_pageContext: PageContext) => {
|
||||||
const options = {
|
const homeShouts = await apiClient.getShouts({
|
||||||
filters: { published: true },
|
filters: { published: true },
|
||||||
limit: PRERENDERED_ARTICLES_COUNT,
|
limit: PRERENDERED_ARTICLES_COUNT,
|
||||||
}
|
})
|
||||||
const homeShouts = await apiClient.getShouts({ options })
|
|
||||||
const pageProps: PageProps = { homeShouts, seo: { title: '' } }
|
const pageProps: PageProps = { homeShouts, seo: { title: '' } }
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -4,10 +4,8 @@ import type { PageContext } from '../renderer/types'
|
||||||
import { apiClient } from '../graphql/client/core'
|
import { apiClient } from '../graphql/client/core'
|
||||||
|
|
||||||
export const onBeforeRender = async (pageContext: PageContext) => {
|
export const onBeforeRender = async (pageContext: PageContext) => {
|
||||||
const { q } = pageContext.routeParams
|
const { q: text } = pageContext.routeParams
|
||||||
|
const searchResults = await apiClient.getShoutsSearch({ text, limit: 50 })
|
||||||
const searchResults = await apiClient.getShoutsSearch({ text: q, limit: 50 })
|
|
||||||
|
|
||||||
const pageProps: PageProps = { searchResults, seo: { title: '' } }
|
const pageProps: PageProps = { searchResults, seo: { title: '' } }
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -138,7 +138,7 @@ export const loadShouts = async (
|
||||||
options: LoadShoutsOptions,
|
options: LoadShoutsOptions,
|
||||||
): Promise<{ hasMore: boolean; newShouts: Shout[] }> => {
|
): Promise<{ hasMore: boolean; newShouts: Shout[] }> => {
|
||||||
options.limit += 1
|
options.limit += 1
|
||||||
const newShouts = await apiClient.getShouts({ options })
|
const newShouts = await apiClient.getShouts(options)
|
||||||
const hasMore = newShouts ?? newShouts.length === options.limit + 1
|
const hasMore = newShouts ?? newShouts.length === options.limit + 1
|
||||||
|
|
||||||
if (hasMore) {
|
if (hasMore) {
|
||||||
|
@ -155,7 +155,7 @@ export const loadMyFeed = async (
|
||||||
options: LoadShoutsOptions,
|
options: LoadShoutsOptions,
|
||||||
): Promise<{ hasMore: boolean; newShouts: Shout[] }> => {
|
): Promise<{ hasMore: boolean; newShouts: Shout[] }> => {
|
||||||
options.limit += 1
|
options.limit += 1
|
||||||
const newShouts = await apiClient.getMyFeed({ options })
|
const newShouts = await apiClient.getMyFeed(options)
|
||||||
const hasMore = newShouts ?? newShouts.length === options.limit + 1
|
const hasMore = newShouts ?? newShouts.length === options.limit + 1
|
||||||
|
|
||||||
if (hasMore) {
|
if (hasMore) {
|
||||||
|
@ -197,7 +197,7 @@ export const loadTopMonthArticles = async (): Promise<void> => {
|
||||||
order_by: 'rating_stat',
|
order_by: 'rating_stat',
|
||||||
limit: TOP_MONTH_ARTICLES_COUNT,
|
limit: TOP_MONTH_ARTICLES_COUNT,
|
||||||
}
|
}
|
||||||
const articles = await apiClient.getShouts({ options })
|
const articles = await apiClient.getShouts(options)
|
||||||
addArticles(articles)
|
addArticles(articles)
|
||||||
setTopMonthArticles(articles)
|
setTopMonthArticles(articles)
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ export const loadTopArticles = async (): Promise<void> => {
|
||||||
order_by: 'rating_stat',
|
order_by: 'rating_stat',
|
||||||
limit: TOP_ARTICLES_COUNT,
|
limit: TOP_ARTICLES_COUNT,
|
||||||
}
|
}
|
||||||
const articles = await apiClient.getShouts({ options })
|
const articles = await apiClient.getShouts(options)
|
||||||
addArticles(articles)
|
addArticles(articles)
|
||||||
setTopArticles(articles)
|
setTopArticles(articles)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ export const resetSortedLayoutShouts = () => {
|
||||||
|
|
||||||
export const loadLayoutShoutsBy = async (options: LoadShoutsOptions): Promise<{ hasMore: boolean }> => {
|
export const loadLayoutShoutsBy = async (options: LoadShoutsOptions): Promise<{ hasMore: boolean }> => {
|
||||||
options.limit += 1
|
options.limit += 1
|
||||||
const newLayoutShouts = await apiClient.getShouts({ options })
|
const newLayoutShouts = await apiClient.getShouts(options)
|
||||||
const hasMore = newLayoutShouts.length === options.limit + 1
|
const hasMore = newLayoutShouts.length === options.limit + 1
|
||||||
|
|
||||||
if (hasMore) {
|
if (hasMore) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user