diff --git a/codegen.yml b/codegen.yml
index 44d1e541..2219d008 100644
--- a/codegen.yml
+++ b/codegen.yml
@@ -1,5 +1,5 @@
overwrite: true
-schema: 'http://localhost:8080'
+schema: 'https://testapi.discours.io'
generates:
src/graphql/introspec.gen.ts:
plugins:
diff --git a/public/icons/user-default.svg b/public/icons/user-default.svg
new file mode 100644
index 00000000..b51449e1
--- /dev/null
+++ b/public/icons/user-default.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/components/Article/Comment.tsx b/src/components/Article/Comment.tsx
index 4bee6c47..870dc134 100644
--- a/src/components/Article/Comment.tsx
+++ b/src/components/Article/Comment.tsx
@@ -54,7 +54,7 @@ export default (props: {
-
+
diff --git a/src/components/Article/CommentsTree.tsx b/src/components/Article/CommentsTree.tsx
new file mode 100644
index 00000000..9f1a2f31
--- /dev/null
+++ b/src/components/Article/CommentsTree.tsx
@@ -0,0 +1,85 @@
+import { For, Show } from 'solid-js/web'
+import { useSession } from '../../context/session'
+import Comment from './Comment'
+import { t } from '../../utils/intl'
+import { showModal } from '../../stores/ui'
+import styles from '../../styles/Article.module.scss'
+import { useReactionsStore } from '../../stores/zine/reactions'
+import { createEffect, createMemo, createSignal, onMount, Suspense } from 'solid-js'
+import type { Reaction } from '../../graphql/types.gen'
+
+const ARTICLE_COMMENTS_PAGE_SIZE = 50
+const MAX_COMMENT_LEVEL = 6
+
+export const CommentsTree = (props: { shout: string; reactions?: Reaction[] }) => {
+ const [getCommentsPage, setCommentsPage] = createSignal(0)
+ const [isCommentsLoading, setIsCommentsLoading] = createSignal(false)
+ const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false)
+ const { session } = useSession()
+ const { sortedReactions, loadReactionsBy } = useReactionsStore({ reactions: props.reactions })
+ const reactions = createMemo(() => sortedReactions()) // .filter(r => r.shout.slug === props.shout) )
+ const loadMore = async () => {
+ try {
+ const page = getCommentsPage()
+ setIsCommentsLoading(true)
+
+ const { hasMore } = await loadReactionsBy({
+ by: { shout: props.shout, comment: true },
+ limit: ARTICLE_COMMENTS_PAGE_SIZE,
+ offset: page * ARTICLE_COMMENTS_PAGE_SIZE
+ })
+ setIsLoadMoreButtonVisible(hasMore)
+ } finally {
+ setIsCommentsLoading(false)
+ }
+ }
+ const getCommentById = (cid) => reactions().find((r) => r.id === cid)
+ const getCommentLevel = (c: Reaction, level = 0) => {
+ if (c && c.replyTo && level < MAX_COMMENT_LEVEL) {
+ return getCommentLevel(getCommentById(c.replyTo), level + 1)
+ }
+ return level
+ }
+ onMount(async () => await loadMore())
+ return (
+ <>
+
+
+
+
+ {(reaction: Reaction) => (
+
+ )}
+
+
+
+
+
+
+
+ }
+ >
+
+
+ >
+ )
+}
diff --git a/src/components/Article/FullArticle.tsx b/src/components/Article/FullArticle.tsx
index d71cb3f6..e954f770 100644
--- a/src/components/Article/FullArticle.tsx
+++ b/src/components/Article/FullArticle.tsx
@@ -1,33 +1,19 @@
import { capitalize } from '../../utils'
import './Full.scss'
import { Icon } from '../_shared/Icon'
-import ArticleComment from './Comment'
import { AuthorCard } from '../Author/Card'
import { createMemo, createSignal, For, onMount, Show } from 'solid-js'
import type { Author, Reaction, Shout } from '../../graphql/types.gen'
import { t } from '../../utils/intl'
-import { showModal } from '../../stores/ui'
import MD from './MD'
import { SharePopup } from './SharePopup'
-import { useSession } from '../../context/session'
import stylesHeader from '../Nav/Header.module.scss'
import styles from '../../styles/Article.module.scss'
import RatingControl from './RatingControl'
import { clsx } from 'clsx'
-
-const MAX_COMMENT_LEVEL = 6
-
-const getCommentLevel = (comment: Reaction, level = 0) => {
- if (comment && comment.replyTo && level < MAX_COMMENT_LEVEL) {
- return 0 // FIXME: getCommentLevel(commentsById[c.replyTo], level + 1)
- }
- return level
-}
-
+import { CommentsTree } from './CommentsTree'
interface ArticleProps {
article: Shout
- reactions: Reaction[]
- isCommentsLoading: boolean
}
const formatDate = (date: Date) => {
@@ -41,7 +27,6 @@ const formatDate = (date: Date) => {
}
export const FullArticle = (props: ArticleProps) => {
- const { session } = useSession()
const formattedDate = createMemo(() => formatDate(new Date(props.article.createdAt)))
const [isSharePopupVisible, setIsSharePopupVisible] = createSignal(false)
@@ -52,12 +37,6 @@ export const FullArticle = (props: ArticleProps) => {
)
onMount(() => {
- const script = document.createElement('script')
- script.async = true
- script.src = 'https://ackee.discours.io/increment.js'
- script.dataset.ackeeServer = 'https://ackee.discours.io'
- script.dataset.ackeeDomainId = '1004abeb-89b2-4e85-ad97-74f8d2c8ed2d'
- document.body.appendChild(script)
const windowHash = window.location.hash
if (windowHash?.length > 0) {
const comments = document.querySelector(windowHash)
@@ -114,11 +93,6 @@ export const FullArticle = (props: ArticleProps) => {
-
-
- {props.article.stat?.rating || ''}
-
-
{props.article.stat?.commented || ''}
@@ -153,7 +127,7 @@ export const FullArticle = (props: ArticleProps) => {
{/**/}
- {formattedDate}
+ {formattedDate()}
@@ -187,39 +161,7 @@ export const FullArticle = (props: ArticleProps) => {
)}
-
-
-
-
- r.body)}>
- {(reaction) => (
-
- )}
-
-
-
-
-
-
-
-
+
)
diff --git a/src/components/Author/Userpic.tsx b/src/components/Author/Userpic.tsx
index 75dc918b..77bf37b9 100644
--- a/src/components/Author/Userpic.tsx
+++ b/src/components/Author/Userpic.tsx
@@ -32,7 +32,7 @@ export default (props: UserpicProps) => {
when={props.user && props.user.userpic === ''}
fallback={
@@ -48,7 +48,7 @@ export default (props: UserpicProps) => {
when={props.user && props.user.userpic === ''}
fallback={
diff --git a/src/components/Nav/HeaderAuth.tsx b/src/components/Nav/HeaderAuth.tsx
index dda42bef..aa3c6201 100644
--- a/src/components/Nav/HeaderAuth.tsx
+++ b/src/components/Nav/HeaderAuth.tsx
@@ -70,7 +70,7 @@ export const HeaderAuth = (props: HeaderAuthProps) => {
}
diff --git a/src/components/Views/Article.tsx b/src/components/Views/Article.tsx
index 6dab58d6..1fd600ed 100644
--- a/src/components/Views/Article.tsx
+++ b/src/components/Views/Article.tsx
@@ -1,4 +1,4 @@
-import { createEffect, createSignal, Show, Suspense } from 'solid-js'
+import { createEffect, createMemo, createSignal, onMount, Show, Suspense } from 'solid-js'
import { FullArticle } from '../Article/FullArticle'
import { t } from '../../utils/intl'
import type { Shout, Reaction } from '../../graphql/types.gen'
@@ -9,34 +9,20 @@ interface ArticlePageProps {
reactions?: Reaction[]
}
-const ARTICLE_COMMENTS_PAGE_SIZE = 50
-
export const ArticleView = (props: ArticlePageProps) => {
- const [getCommentsPage] = createSignal(0)
- const [getIsCommentsLoading, setIsCommentsLoading] = createSignal(false)
- const { reactionsByShout, loadReactionsBy } = useReactionsStore({ reactions: props.reactions })
-
- createEffect(async () => {
- try {
- setIsCommentsLoading(true)
- await loadReactionsBy({
- by: { shout: props.article.slug, comment: true },
- limit: ARTICLE_COMMENTS_PAGE_SIZE,
- offset: getCommentsPage() * ARTICLE_COMMENTS_PAGE_SIZE
- })
- } finally {
- setIsCommentsLoading(false)
- }
+ onMount(() => {
+ const script = document.createElement('script')
+ script.async = true
+ script.src = 'https://ackee.discours.io/increment.js'
+ script.dataset.ackeeServer = 'https://ackee.discours.io'
+ script.dataset.ackeeDomainId = '1004abeb-89b2-4e85-ad97-74f8d2c8ed2d'
+ document.body.appendChild(script)
})
return (
{t('Loading')}} when={props.article}>
-
+
)
diff --git a/src/graphql/query/reactions-load-by.ts b/src/graphql/query/reactions-load-by.ts
index 90544861..a42082cf 100644
--- a/src/graphql/query/reactions-load-by.ts
+++ b/src/graphql/query/reactions-load-by.ts
@@ -1,5 +1,7 @@
import { gql } from '@urql/core'
+// FIXME: backend query
+
export default gql`
query LoadReactions($by: ReactionBy!, $limit: Int, $offset: Int) {
loadReactionsBy(by: $by, limit: $limit, offset: $offset) {
@@ -10,6 +12,9 @@ export default gql`
# id
# kind
#}
+ #shout {
+ # slug
+ #}
createdBy {
name
slug
diff --git a/src/graphql/types.gen.ts b/src/graphql/types.gen.ts
index 142fb840..f55c8788 100644
--- a/src/graphql/types.gen.ts
+++ b/src/graphql/types.gen.ts
@@ -54,17 +54,17 @@ export type AuthorsBy = {
}
export type Chat = {
- admins?: Maybe>>
+ admins?: Maybe>>
createdAt: Scalars['Int']
- createdBy: User
+ createdBy: Scalars['String']
description?: Maybe
id: Scalars['String']
- messages: Array>
+ messages?: Maybe>>
private?: Maybe
title?: Maybe
unread?: Maybe
updatedAt: Scalars['Int']
- users: Array>
+ users: Array>
}
export type ChatInput = {
@@ -136,6 +136,7 @@ export type LoadShoutsOptions = {
offset?: InputMaybe
order_by?: InputMaybe
order_by_desc?: InputMaybe
+ with_author_captions?: InputMaybe
}
export type Message = {
@@ -178,7 +179,6 @@ export type Mutation = {
follow: Result
getSession: AuthResult
inviteAuthor: Result
- inviteChat: Result
markAsRead: Result
rateUser: Result
registerUser: AuthResult
@@ -214,7 +214,7 @@ export type MutationCreateReactionArgs = {
}
export type MutationCreateShoutArgs = {
- inp: ShoutInput
+ input: ShoutInput
}
export type MutationCreateTopicArgs = {
@@ -252,11 +252,6 @@ export type MutationInviteAuthorArgs = {
shout: Scalars['String']
}
-export type MutationInviteChatArgs = {
- chatId: Scalars['String']
- userslug: Scalars['String']
-}
-
export type MutationMarkAsReadArgs = {
chatId: Scalars['String']
ids: Array>