fmt
This commit is contained in:
parent
01e7dec615
commit
b61b19a119
|
@ -4,12 +4,7 @@ import { useFeed } from '~/context/feed'
|
||||||
import { useLocalize } from '~/context/localize'
|
import { useLocalize } from '~/context/localize'
|
||||||
import { COMMENTS_PER_PAGE, useReactions } from '~/context/reactions'
|
import { COMMENTS_PER_PAGE, useReactions } from '~/context/reactions'
|
||||||
import { useSession } from '~/context/session'
|
import { useSession } from '~/context/session'
|
||||||
import {
|
import { Reaction, ReactionKind, ReactionSort, Shout } from '~/graphql/schema/core.gen'
|
||||||
Reaction,
|
|
||||||
ReactionKind,
|
|
||||||
ReactionSort,
|
|
||||||
Shout
|
|
||||||
} from '~/graphql/schema/core.gen'
|
|
||||||
import { byCreated, byStat } from '~/lib/sort'
|
import { byCreated, byStat } from '~/lib/sort'
|
||||||
import { SortFunction } from '~/types/common'
|
import { SortFunction } from '~/types/common'
|
||||||
import { Button } from '../_shared/Button'
|
import { Button } from '../_shared/Button'
|
||||||
|
|
|
@ -26,8 +26,14 @@ export const RatingControl = (props: RatingControlProps) => {
|
||||||
const [_, changeSearchParams] = useSearchParams()
|
const [_, changeSearchParams] = useSearchParams()
|
||||||
const snackbar = useSnackbar()
|
const snackbar = useSnackbar()
|
||||||
const { session } = useSession()
|
const { session } = useSession()
|
||||||
const { reactionEntities, reactionsByShout, createReaction, deleteReaction, loadShoutRatings, loadCommentRatings } =
|
const {
|
||||||
useReactions()
|
reactionEntities,
|
||||||
|
reactionsByShout,
|
||||||
|
createReaction,
|
||||||
|
deleteReaction,
|
||||||
|
loadShoutRatings,
|
||||||
|
loadCommentRatings
|
||||||
|
} = useReactions()
|
||||||
const [myRate, setMyRate] = createSignal<Reaction | undefined>()
|
const [myRate, setMyRate] = createSignal<Reaction | undefined>()
|
||||||
const [ratingReactions, setRatingReactions] = createSignal<Reaction[]>([])
|
const [ratingReactions, setRatingReactions] = createSignal<Reaction[]>([])
|
||||||
const [isLoading, setIsLoading] = createSignal(false)
|
const [isLoading, setIsLoading] = createSignal(false)
|
||||||
|
@ -85,7 +91,7 @@ export const RatingControl = (props: RatingControlProps) => {
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
} catch(err) {
|
} catch (err) {
|
||||||
snackbar?.showSnackbar({ type: 'error', body: `${t('Error')}: ${error || err || ''}` })
|
snackbar?.showSnackbar({ type: 'error', body: `${t('Error')}: ${error || err || ''}` })
|
||||||
}
|
}
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
|
|
|
@ -261,7 +261,6 @@ export const AuthorView = (props: AuthorViewProps) => {
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<AuthorFeed />
|
<AuthorFeed />
|
||||||
|
|
||||||
</Match>
|
</Match>
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -53,14 +53,12 @@ export const LoadMoreWrapper = (props: LoadMoreProps) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{props.children}
|
{props.children}
|
||||||
<Show when={isLoading()}><Loading /></Show>
|
<Show when={isLoading()}>
|
||||||
|
<Loading />
|
||||||
|
</Show>
|
||||||
<Show when={isLoadMoreButtonVisible() && !props.hidden && !isLoading()}>
|
<Show when={isLoadMoreButtonVisible() && !props.hidden && !isLoading()}>
|
||||||
<div class="load-more-container">
|
<div class="load-more-container">
|
||||||
<Button
|
<Button onClick={loadItems} value={t('Load more')} title={`${items().length} ${t('loaded')}`} />
|
||||||
onClick={loadItems}
|
|
||||||
value={t('Load more')}
|
|
||||||
title={`${items().length} ${t('loaded')}`}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -2,7 +2,12 @@ import type { JSX } from 'solid-js'
|
||||||
|
|
||||||
import { createContext, onCleanup, useContext } from 'solid-js'
|
import { createContext, onCleanup, useContext } from 'solid-js'
|
||||||
import { createStore, reconcile } from 'solid-js/store'
|
import { createStore, reconcile } from 'solid-js/store'
|
||||||
import { loadCommentRatings, loadReactions, loadShoutComments, loadShoutRatings } from '~/graphql/api/public'
|
import {
|
||||||
|
loadCommentRatings,
|
||||||
|
loadReactions,
|
||||||
|
loadShoutComments,
|
||||||
|
loadShoutRatings
|
||||||
|
} from '~/graphql/api/public'
|
||||||
import createReactionMutation from '~/graphql/mutation/core/reaction-create'
|
import createReactionMutation from '~/graphql/mutation/core/reaction-create'
|
||||||
import destroyReactionMutation from '~/graphql/mutation/core/reaction-destroy'
|
import destroyReactionMutation from '~/graphql/mutation/core/reaction-destroy'
|
||||||
import updateReactionMutation from '~/graphql/mutation/core/reaction-update'
|
import updateReactionMutation from '~/graphql/mutation/core/reaction-update'
|
||||||
|
@ -69,7 +74,11 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadShoutRatingsAdding = async (shout: number, limit = RATINGS_PER_PAGE, offset = 0): Promise<Reaction[]> => {
|
const loadShoutRatingsAdding = async (
|
||||||
|
shout: number,
|
||||||
|
limit = RATINGS_PER_PAGE,
|
||||||
|
offset = 0
|
||||||
|
): Promise<Reaction[]> => {
|
||||||
const fetcher = await loadShoutRatings({ shout, limit, offset })
|
const fetcher = await loadShoutRatings({ shout, limit, offset })
|
||||||
const result = (await fetcher()) || []
|
const result = (await fetcher()) || []
|
||||||
console.debug('[context.reactions] shout ratings loaded', result)
|
console.debug('[context.reactions] shout ratings loaded', result)
|
||||||
|
@ -77,7 +86,11 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadCommentRatingsAdding = async (comment: number, limit = RATINGS_PER_PAGE, offset = 0): Promise<Reaction[]> => {
|
const loadCommentRatingsAdding = async (
|
||||||
|
comment: number,
|
||||||
|
limit = RATINGS_PER_PAGE,
|
||||||
|
offset = 0
|
||||||
|
): Promise<Reaction[]> => {
|
||||||
const fetcher = await loadCommentRatings({ comment, limit, offset })
|
const fetcher = await loadCommentRatings({ comment, limit, offset })
|
||||||
const result = (await fetcher()) || []
|
const result = (await fetcher()) || []
|
||||||
console.debug('[context.reactions] shout ratings loaded', result)
|
console.debug('[context.reactions] shout ratings loaded', result)
|
||||||
|
@ -85,7 +98,11 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadShoutCommentsAdding = async (shout: number, limit = COMMENTS_PER_PAGE, offset = 0): Promise<Reaction[]> => {
|
const loadShoutCommentsAdding = async (
|
||||||
|
shout: number,
|
||||||
|
limit = COMMENTS_PER_PAGE,
|
||||||
|
offset = 0
|
||||||
|
): Promise<Reaction[]> => {
|
||||||
const fetcher = await loadShoutComments({ shout, limit, offset })
|
const fetcher = await loadShoutComments({ shout, limit, offset })
|
||||||
const result = (await fetcher()) || []
|
const result = (await fetcher()) || []
|
||||||
console.debug('[context.reactions] shout comments loaded', result)
|
console.debug('[context.reactions] shout comments loaded', result)
|
||||||
|
|
|
@ -62,7 +62,7 @@ export const loadShouts = (options: LoadShoutsOptions) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadShoutComments = (options: QueryLoad_Shout_RatingsArgs) => {
|
export const loadShoutComments = (options: QueryLoad_Shout_RatingsArgs) => {
|
||||||
const page = `${options.offset || 0}-${(options.limit||1) + (options.offset || 0)}`
|
const page = `${options.offset || 0}-${(options.limit || 1) + (options.offset || 0)}`
|
||||||
return cache(async () => {
|
return cache(async () => {
|
||||||
const resp = await defaultClient.query(loadShoutCommentsQuery, options).toPromise()
|
const resp = await defaultClient.query(loadShoutCommentsQuery, options).toPromise()
|
||||||
const result = resp?.data?.load_reactions_by
|
const result = resp?.data?.load_reactions_by
|
||||||
|
@ -71,7 +71,7 @@ export const loadShoutComments = (options: QueryLoad_Shout_RatingsArgs) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadShoutRatings = (options: QueryLoad_Shout_RatingsArgs) => {
|
export const loadShoutRatings = (options: QueryLoad_Shout_RatingsArgs) => {
|
||||||
const page = `${options.offset || 0}-${(options.limit||1) + (options.offset || 0)}`
|
const page = `${options.offset || 0}-${(options.limit || 1) + (options.offset || 0)}`
|
||||||
return cache(async () => {
|
return cache(async () => {
|
||||||
const resp = await defaultClient.query(loadShoutRatingsQuery, options).toPromise()
|
const resp = await defaultClient.query(loadShoutRatingsQuery, options).toPromise()
|
||||||
const result = resp?.data?.load_reactions_by
|
const result = resp?.data?.load_reactions_by
|
||||||
|
@ -81,7 +81,7 @@ export const loadShoutRatings = (options: QueryLoad_Shout_RatingsArgs) => {
|
||||||
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: FIXME: wait backend
|
// biome-ignore lint/suspicious/noExplicitAny: FIXME: wait backend
|
||||||
export const loadCommentRatings = (options: any) => {
|
export const loadCommentRatings = (options: any) => {
|
||||||
const page = `${options.offset || 0}-${(options.limit||1) + (options.offset || 0)}`
|
const page = `${options.offset || 0}-${(options.limit || 1) + (options.offset || 0)}`
|
||||||
return cache(async () => {
|
return cache(async () => {
|
||||||
const resp = await defaultClient.query(loadCommentRatingsQuery, options).toPromise()
|
const resp = await defaultClient.query(loadCommentRatingsQuery, options).toPromise()
|
||||||
const result = resp?.data?.load_reactions_by
|
const result = resp?.data?.load_reactions_by
|
||||||
|
|
|
@ -54,7 +54,10 @@ export default function AuthorPage(props: RouteSectionProps<AuthorPageProps>) {
|
||||||
const { authorsEntities } = useAuthors()
|
const { authorsEntities } = useAuthors()
|
||||||
const { addFeed, feedByAuthor } = useFeed()
|
const { addFeed, feedByAuthor } = useFeed()
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
const author = createAsync(async() => props.data.author || authorsEntities()[props.params.slug] || await fetchAuthor(props.params.slug))
|
const author = createAsync(
|
||||||
|
async () =>
|
||||||
|
props.data.author || authorsEntities()[props.params.slug] || (await fetchAuthor(props.params.slug))
|
||||||
|
)
|
||||||
const shoutsByAuthor = createMemo(() => feedByAuthor()[props.params.slug])
|
const shoutsByAuthor = createMemo(() => feedByAuthor()[props.params.slug])
|
||||||
const title = createMemo(() => `${author()?.name || ''}`)
|
const title = createMemo(() => `${author()?.name || ''}`)
|
||||||
const cover = createMemo(() =>
|
const cover = createMemo(() =>
|
||||||
|
@ -74,7 +77,6 @@ export default function AuthorPage(props: RouteSectionProps<AuthorPageProps>) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// author shouts
|
// author shouts
|
||||||
const loadAuthorShoutsMore = async (offset: number) => {
|
const loadAuthorShoutsMore = async (offset: number) => {
|
||||||
const loadedShouts = await fetchAuthorShouts(props.params.slug, offset)
|
const loadedShouts = await fetchAuthorShouts(props.params.slug, offset)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user