Merge branch 'feature/empty-feed' of https://github.com/Discours/discoursio-webapp into feature/empty-feed
This commit is contained in:
commit
7ba6bb2f97
|
@ -1,7 +1,7 @@
|
||||||
import type { Topic } from '../../graphql/schema/core.gen'
|
import type { Author, Topic } from '../../graphql/schema/core.gen'
|
||||||
|
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import { Show, createEffect, createSignal } from 'solid-js'
|
import { For, Show, createEffect, createSignal } from 'solid-js'
|
||||||
|
|
||||||
import { useFollowing } from '../../context/following'
|
import { useFollowing } from '../../context/following'
|
||||||
import { useLocalize } from '../../context/localize'
|
import { useLocalize } from '../../context/localize'
|
||||||
|
@ -9,10 +9,13 @@ import { useSession } from '../../context/session'
|
||||||
import { FollowingEntity } from '../../graphql/schema/core.gen'
|
import { FollowingEntity } from '../../graphql/schema/core.gen'
|
||||||
import { Button } from '../_shared/Button'
|
import { Button } from '../_shared/Button'
|
||||||
|
|
||||||
|
import stylesCard from '../Author/AuthorCard/AuthorCard.module.scss'
|
||||||
|
import { Userpic } from '../Author/Userpic'
|
||||||
import styles from './Full.module.scss'
|
import styles from './Full.module.scss'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
topic: Topic
|
topic: Topic
|
||||||
|
followers?: Author[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FullTopic = (props: Props) => {
|
export const FullTopic = (props: Props) => {
|
||||||
|
@ -40,6 +43,31 @@ export const FullTopic = (props: Props) => {
|
||||||
return (
|
return (
|
||||||
<div class={clsx(styles.topicHeader, 'col-md-16 col-lg-12 offset-md-4 offset-lg-6')}>
|
<div class={clsx(styles.topicHeader, 'col-md-16 col-lg-12 offset-md-4 offset-lg-6')}>
|
||||||
<h1>#{props.topic?.title}</h1>
|
<h1>#{props.topic?.title}</h1>
|
||||||
|
|
||||||
|
<div class={stylesCard.subscribersContainer}>
|
||||||
|
<Show when={props.followers && props.followers.length > 0}>
|
||||||
|
<a href="?m=followers" class={stylesCard.subscribers}>
|
||||||
|
<For each={props.followers.slice(0, 3)}>
|
||||||
|
{(f) => (
|
||||||
|
<Userpic size={'XS'} name={f.name} userpic={f.pic} class={stylesCard.subscribersItem} />
|
||||||
|
)}
|
||||||
|
</For>
|
||||||
|
<div class={stylesCard.subscribersCounter}>
|
||||||
|
{t('SubscriberWithCount', {
|
||||||
|
count: props.followers.length ?? 0,
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</Show>
|
||||||
|
<Show when={props.topic?.stat?.shouts}>
|
||||||
|
<div class={stylesCard.subscribersCounter}>
|
||||||
|
{t('PublicationsWithCount', {
|
||||||
|
count: props.topic?.stat?.shouts ?? 0,
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</Show>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p innerHTML={props.topic?.body} />
|
<p innerHTML={props.topic?.body} />
|
||||||
<div class={clsx(styles.topicActions)}>
|
<div class={clsx(styles.topicActions)}>
|
||||||
<Button
|
<Button
|
||||||
|
@ -52,7 +80,7 @@ export const FullTopic = (props: Props) => {
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<Show when={props.topic?.pic}>
|
<Show when={props.topic?.pic}>
|
||||||
<img src={props.topic.pic} alt={props.topic?.title} />
|
<img src={props.topic?.pic} alt={props.topic?.title} />
|
||||||
</Show>
|
</Show>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -67,7 +67,7 @@ export const AuthorView = (props: Props) => {
|
||||||
const { authors, profile, topics } = appdata
|
const { authors, profile, topics } = appdata
|
||||||
setFollowers(myFollowers)
|
setFollowers(myFollowers)
|
||||||
setAuthor(profile)
|
setAuthor(profile)
|
||||||
setFollowing([...authors, ...topics])
|
setFollowing([...(authors || []), ...(topics || [])])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -260,7 +260,9 @@ export const AuthorView = (props: Props) => {
|
||||||
</div>
|
</div>
|
||||||
</Match>
|
</Match>
|
||||||
<Match when={getPage().route === 'authorComments'}>
|
<Match when={getPage().route === 'authorComments'}>
|
||||||
<Show when={session()?.user?.app_data?.profile?.slug === props.authorSlug && !commented().length}>
|
<Show
|
||||||
|
when={session()?.user?.app_data?.profile?.slug === props.authorSlug && !commented()?.length}
|
||||||
|
>
|
||||||
<div class="wide-container">
|
<div class="wide-container">
|
||||||
<Placeholder type={getPage().route} mode="profile" />
|
<Placeholder type={getPage().route} mode="profile" />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { LoadShoutsOptions, Shout, Topic } from '../../graphql/schema/core.gen'
|
import { Author, LoadShoutsOptions, Shout, Topic } from '../../graphql/schema/core.gen'
|
||||||
|
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import { For, Show, createEffect, createMemo, createSignal, on, onMount } from 'solid-js'
|
import { For, Show, createEffect, createMemo, createSignal, on, onMount } from 'solid-js'
|
||||||
|
@ -33,6 +33,7 @@ interface Props {
|
||||||
topic: Topic
|
topic: Topic
|
||||||
shouts: Shout[]
|
shouts: Shout[]
|
||||||
topicSlug: string
|
topicSlug: string
|
||||||
|
followers?: Author[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PRERENDERED_ARTICLES_COUNT = 28
|
export const PRERENDERED_ARTICLES_COUNT = 28
|
||||||
|
@ -56,6 +57,11 @@ export const TopicView = (props: Props) => {
|
||||||
setTopic(topics[props.topicSlug])
|
setTopic(topics[props.topicSlug])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
const [followers, setFollowers] = createSignal<Author[]>(props.followers || [])
|
||||||
|
const loadTopicFollowers = async () => {
|
||||||
|
const result = await apiClient.getTopicFollowers({ slug: props.topicSlug })
|
||||||
|
setFollowers(result)
|
||||||
|
}
|
||||||
|
|
||||||
const loadFavoriteTopArticles = async (topic: string) => {
|
const loadFavoriteTopArticles = async (topic: string) => {
|
||||||
const options: LoadShoutsOptions = {
|
const options: LoadShoutsOptions = {
|
||||||
|
@ -89,8 +95,11 @@ export const TopicView = (props: Props) => {
|
||||||
|
|
||||||
createEffect(
|
createEffect(
|
||||||
on(
|
on(
|
||||||
() => topic(),
|
() => topic()?.id,
|
||||||
() => loadRandom(),
|
(_) => {
|
||||||
|
loadTopicFollowers()
|
||||||
|
loadRandom()
|
||||||
|
},
|
||||||
{ defer: true },
|
{ defer: true },
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -158,7 +167,7 @@ export const TopicView = (props: Props) => {
|
||||||
<Meta name="twitter:card" content="summary_large_image" />
|
<Meta name="twitter:card" content="summary_large_image" />
|
||||||
<Meta name="twitter:title" content={title()} />
|
<Meta name="twitter:title" content={title()} />
|
||||||
<Meta name="twitter:description" content={description()} />
|
<Meta name="twitter:description" content={description()} />
|
||||||
<FullTopic topic={topic()} />
|
<FullTopic topic={topic()} followers={followers()} />
|
||||||
<div class="wide-container">
|
<div class="wide-container">
|
||||||
<div class={clsx(styles.groupControls, 'row group__controls')}>
|
<div class={clsx(styles.groupControls, 'row group__controls')}>
|
||||||
<div class="col-md-16">
|
<div class="col-md-16">
|
||||||
|
|
|
@ -5,6 +5,7 @@ import type {
|
||||||
LoadShoutsOptions,
|
LoadShoutsOptions,
|
||||||
MutationDelete_ShoutArgs,
|
MutationDelete_ShoutArgs,
|
||||||
ProfileInput,
|
ProfileInput,
|
||||||
|
QueryGet_Topic_FollowersArgs,
|
||||||
QueryLoad_Authors_ByArgs,
|
QueryLoad_Authors_ByArgs,
|
||||||
QueryLoad_Shouts_Random_TopArgs,
|
QueryLoad_Shouts_Random_TopArgs,
|
||||||
QueryLoad_Shouts_SearchArgs,
|
QueryLoad_Shouts_SearchArgs,
|
||||||
|
@ -44,6 +45,7 @@ import authorsAll from '../query/core/authors-all'
|
||||||
import authorsLoadBy from '../query/core/authors-load-by'
|
import authorsLoadBy from '../query/core/authors-load-by'
|
||||||
import reactionsLoadBy from '../query/core/reactions-load-by'
|
import reactionsLoadBy from '../query/core/reactions-load-by'
|
||||||
import topicBySlug from '../query/core/topic-by-slug'
|
import topicBySlug from '../query/core/topic-by-slug'
|
||||||
|
import topicFollowers from '../query/core/topic-followers'
|
||||||
import topicsAll from '../query/core/topics-all'
|
import topicsAll from '../query/core/topics-all'
|
||||||
import topicsRandomQuery from '../query/core/topics-random'
|
import topicsRandomQuery from '../query/core/topics-random'
|
||||||
|
|
||||||
|
@ -129,6 +131,11 @@ export const apiClient = {
|
||||||
return response.data.get_author_followers
|
return response.data.get_author_followers
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getTopicFollowers: async ({ slug }: QueryGet_Topic_FollowersArgs): Promise<Author[]> => {
|
||||||
|
const response = await publicGraphQLClient.query(topicFollowers, { slug }).toPromise()
|
||||||
|
return response.data.get_topic_followers
|
||||||
|
},
|
||||||
|
|
||||||
getAuthorFollows: async (params: {
|
getAuthorFollows: async (params: {
|
||||||
slug?: string
|
slug?: string
|
||||||
author_id?: number
|
author_id?: number
|
||||||
|
|
25
src/graphql/query/core/topic-followers.ts
Normal file
25
src/graphql/query/core/topic-followers.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import { gql } from '@urql/core'
|
||||||
|
|
||||||
|
export default gql`
|
||||||
|
query TopicFollowersQuery($slug: String) {
|
||||||
|
get_topic_followers(slug: $slug) {
|
||||||
|
id
|
||||||
|
slug
|
||||||
|
name
|
||||||
|
bio
|
||||||
|
about
|
||||||
|
pic
|
||||||
|
# communities
|
||||||
|
links
|
||||||
|
created_at
|
||||||
|
last_seen
|
||||||
|
stat {
|
||||||
|
shouts
|
||||||
|
authors
|
||||||
|
followers
|
||||||
|
rating
|
||||||
|
comments
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
Loading…
Reference in New Issue
Block a user