(() => JSON.parse(props.article.media || '[]'))
let commentsRef: HTMLDivElement | undefined
@@ -291,40 +306,25 @@ export const FullArticle = (props: Props) => {
})
}
- createEffect(
- on(
- () => props.article,
- () => {
- updateIframeSizes()
- }
- )
- )
-
- onMount(async () => {
- const opts: QueryLoad_Reactions_ByArgs = { by: { shout: props.article.slug }, limit: 999, offset: 0 }
- const _rrr = await loadReactionsBy(opts)
+ onMount(() => {
+ console.debug(props.article)
+ setPages((_) => ({comments: 0, rating: 0}))
addSeen(props.article.slug)
- setIsReactionsLoaded(true)
document.title = props.article.title
+ updateIframeSizes()
window?.addEventListener('resize', updateIframeSizes)
-
onCleanup(() => window.removeEventListener('resize', updateIframeSizes))
-
- createEffect(() => {
- if (props.scrollToComments && commentsRef) {
- scrollTo(commentsRef)
- }
- })
-
- createEffect(() => {
- if (searchParams?.scrollTo === 'comments' && commentsRef) {
- requestAnimationFrame(() => commentsRef && scrollTo(commentsRef))
- changeSearchParams({ scrollTo: undefined })
- }
- })
})
- const shareUrl = getShareUrl({ pathname: `/${props.article.slug || ''}` })
+ createEffect(() => props.scrollToComments && commentsRef && scrollTo(commentsRef))
+ createEffect(() => {
+ if (searchParams?.scrollTo === 'comments' && commentsRef) {
+ requestAnimationFrame(() => commentsRef && scrollTo(commentsRef))
+ changeSearchParams({ scrollTo: undefined })
+ }
+ })
+
+ const shareUrl = createMemo(() => getShareUrl({ pathname: `/${props.article.slug || ''}` }))
const getAuthorName = (a: Author) =>
lang() === 'en' && isCyrillic(a.name || '') ? capitalize(a.slug.replace(/-/, ' ')) : a.name
return (
@@ -346,7 +346,7 @@ export const FullArticle = (props: Props) => {
{props.article.title || ''}
- {props.article.subtitle || ''}
+ {processPrepositions(props.article.subtitle || '')}
@@ -378,7 +378,7 @@ export const FullArticle = (props: Props) => {
-
+
{
title={props.article.title}
description={props.article.description || body() || media()[0]?.body}
imageUrl={props.article.cover || ''}
- shareUrl={shareUrl}
+ shareUrl={shareUrl()}
containerCssClass={stylesHeader.control}
onVisibilityChange={(isVisible) => setIsActionPopupActive(isVisible)}
trigger={
@@ -600,7 +600,7 @@ export const FullArticle = (props: Props) => {
title={props.article.title}
description={props.article.description || body() || media()[0]?.body}
imageUrl={props.article.cover || ''}
- shareUrl={shareUrl}
+ shareUrl={shareUrl()}
/>
>
)
diff --git a/src/context/following.tsx b/src/context/following.tsx
index 13a4810c..15512ef1 100644
--- a/src/context/following.tsx
+++ b/src/context/following.tsx
@@ -33,7 +33,21 @@ interface FollowingContextType {
unfollow: (what: FollowingEntity, slug: string) => Promise
}
-const FollowingContext = createContext({} as FollowingContextType)
+const defaultFollowing = {
+ slug: '',
+ type: 'follow'
+} as FollowingData
+
+const FollowingContext = createContext({
+ following: () => defaultFollowing,
+ followers: () => [],
+ loading: () => false,
+ setFollows: (_follows: AuthorFollowsResult) => undefined,
+ follows: {},
+ loadFollows: () => undefined,
+ follow: (_what: FollowingEntity, _slug: string) => undefined,
+ unfollow: (_what: FollowingEntity, _slug: string) => undefined
+} as unknown as FollowingContextType)
export function useFollowing() {
return useContext(FollowingContext)
@@ -51,8 +65,6 @@ const EMPTY_SUBSCRIPTIONS: AuthorFollowsResult = {
communities: [] as Community[]
}
-const defaultFollowing = { slug: '', type: 'follow' } as FollowingData
-
export const FollowingProvider = (props: { children: JSX.Element }) => {
const [loading, setLoading] = createSignal(false)
const [followers, setFollowers] = createSignal([] as Author[])
diff --git a/src/context/reactions.tsx b/src/context/reactions.tsx
index c9aadab0..7e734ebe 100644
--- a/src/context/reactions.tsx
+++ b/src/context/reactions.tsx
@@ -40,6 +40,7 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
const { mutation } = useGraphQL()
const loadReactionsBy = async (opts: QueryLoad_Reactions_ByArgs): Promise => {
+ !opts.by && console.warn('reactions provider got wrong opts')
const fetcher = await loadReactions(opts)
const result = (await fetcher()) || []
console.debug('[context.reactions] loaded', result)
diff --git a/src/graphql/api/public.ts b/src/graphql/api/public.ts
index de726531..5ef2049b 100644
--- a/src/graphql/api/public.ts
+++ b/src/graphql/api/public.ts
@@ -1,5 +1,6 @@
import { cache } from '@solidjs/router'
import { defaultClient } from '~/context/graphql'
+import getShoutQuery from '~/graphql/query/core/article-load'
import loadShoutsByQuery from '~/graphql/query/core/articles-load-by'
import loadShoutsSearchQuery from '~/graphql/query/core/articles-load-search'
import getAuthorQuery from '~/graphql/query/core/author-by'
@@ -69,10 +70,10 @@ export const loadReactions = (options: QueryLoad_Reactions_ByArgs) => {
}
export const getShout = (options: QueryGet_ShoutArgs) => {
- console.debug('[lib.api] get shout options', options)
+ // console.debug('[lib.api] get shout options', options)
return cache(
async () => {
- const resp = await defaultClient.query(loadReactionsByQuery, { ...options }).toPromise()
+ const resp = await defaultClient.query(getShoutQuery, { ...options }).toPromise()
const result = resp?.data?.get_shout
if (result) return result as Shout
},
diff --git a/src/routes/[slug].tsx b/src/routes/[slug].tsx
index 7a294039..b0e9746c 100644
--- a/src/routes/[slug].tsx
+++ b/src/routes/[slug].tsx
@@ -77,7 +77,7 @@ export default (
}>
}>
diff --git a/src/routes/topic/[slug].tsx b/src/routes/topic/[slug].tsx
index 35ffb375..00b2d1bb 100644
--- a/src/routes/topic/[slug].tsx
+++ b/src/routes/topic/[slug].tsx
@@ -28,9 +28,7 @@ export const route = {
export default (props: RouteSectionProps<{ articles: Shout[] }>) => {
const params = useParams()
- const articles = createAsync(
- async () => props.data.articles || (await fetchTopicShouts(params.slug)) || []
- )
+ const articles = createAsync(async () => props.data.articles || (await fetchTopicShouts(params.slug)) || [])
const { topicEntities } = useTopics()
const { t } = useLocalize()
const topic = createMemo(() => topicEntities?.()[params.slug])