Merge branch 'dev' of github.com:Discours/discoursio-webapp into dev
This commit is contained in:
commit
1a3d7a9520
|
@ -94,10 +94,6 @@ export const App = (props: Props) => {
|
||||||
const is404 = createMemo(() => props.is404)
|
const is404 = createMemo(() => props.is404)
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
if (!searchParams().m) {
|
|
||||||
hideModal()
|
|
||||||
}
|
|
||||||
|
|
||||||
const modal = MODALS[searchParams().m]
|
const modal = MODALS[searchParams().m]
|
||||||
if (modal) {
|
if (modal) {
|
||||||
showModal(modal)
|
showModal(modal)
|
||||||
|
|
|
@ -46,14 +46,13 @@ export const Comment = (props: Props) => {
|
||||||
const canEdit = createMemo(
|
const canEdit = createMemo(
|
||||||
() =>
|
() =>
|
||||||
Boolean(author()?.id) &&
|
Boolean(author()?.id) &&
|
||||||
(props.comment?.created_by?.id === author().id || session()?.user?.roles.includes('editor')),
|
(props.comment?.created_by?.slug === author().slug || session()?.user?.roles.includes('editor')),
|
||||||
)
|
)
|
||||||
|
|
||||||
const comment = createMemo(() => props.comment)
|
const body = createMemo(() => (props.comment.body || '').trim())
|
||||||
const body = createMemo(() => (comment().body || '').trim())
|
|
||||||
|
|
||||||
const remove = async () => {
|
const remove = async () => {
|
||||||
if (comment()?.id) {
|
if (props.comment?.id) {
|
||||||
try {
|
try {
|
||||||
const isConfirmed = await showConfirm({
|
const isConfirmed = await showConfirm({
|
||||||
confirmBody: t('Are you sure you want to delete this comment?'),
|
confirmBody: t('Are you sure you want to delete this comment?'),
|
||||||
|
@ -63,7 +62,7 @@ export const Comment = (props: Props) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (isConfirmed) {
|
if (isConfirmed) {
|
||||||
await deleteReaction(comment().id)
|
await deleteReaction(props.comment.id)
|
||||||
|
|
||||||
await showSnackbar({ body: t('Comment successfully deleted') })
|
await showSnackbar({ body: t('Comment successfully deleted') })
|
||||||
}
|
}
|
||||||
|
@ -113,8 +112,10 @@ export const Comment = (props: Props) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
id={`comment_${comment().id}`}
|
id={`comment_${props.comment.id}`}
|
||||||
class={clsx(styles.comment, props.class, { [styles.isNew]: comment()?.created_at > props.lastSeen })}
|
class={clsx(styles.comment, props.class, {
|
||||||
|
[styles.isNew]: props.comment?.created_at > props.lastSeen,
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
<Show when={!!body()}>
|
<Show when={!!body()}>
|
||||||
<div class={styles.commentContent}>
|
<div class={styles.commentContent}>
|
||||||
|
@ -123,21 +124,21 @@ export const Comment = (props: Props) => {
|
||||||
fallback={
|
fallback={
|
||||||
<div>
|
<div>
|
||||||
<Userpic
|
<Userpic
|
||||||
name={comment().created_by.name}
|
name={props.comment.created_by.name}
|
||||||
userpic={comment().created_by.pic}
|
userpic={props.comment.created_by.pic}
|
||||||
class={clsx({
|
class={clsx({
|
||||||
[styles.compactUserpic]: props.compact,
|
[styles.compactUserpic]: props.compact,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<small>
|
<small>
|
||||||
<a href={`#comment_${comment()?.id}`}>{comment()?.shout.title || ''}</a>
|
<a href={`#comment_${props.comment?.id}`}>{props.comment?.shout.title || ''}</a>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div class={styles.commentDetails}>
|
<div class={styles.commentDetails}>
|
||||||
<div class={styles.commentAuthor}>
|
<div class={styles.commentAuthor}>
|
||||||
<AuthorLink author={comment()?.created_by as Author} />
|
<AuthorLink author={props.comment?.created_by as Author} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Show when={props.isArticleAuthor}>
|
<Show when={props.isArticleAuthor}>
|
||||||
|
@ -148,23 +149,23 @@ export const Comment = (props: Props) => {
|
||||||
<div class={styles.articleLink}>
|
<div class={styles.articleLink}>
|
||||||
<Icon name="arrow-right" class={styles.articleLinkIcon} />
|
<Icon name="arrow-right" class={styles.articleLinkIcon} />
|
||||||
<a
|
<a
|
||||||
href={`${getPagePath(router, 'article', { slug: comment().shout.slug })}?commentId=${
|
href={`${getPagePath(router, 'article', {
|
||||||
comment().id
|
slug: props.comment.shout.slug,
|
||||||
}`}
|
})}?commentId=${props.comment.id}`}
|
||||||
>
|
>
|
||||||
{comment().shout.title}
|
{props.comment.shout.title}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
<CommentDate showOnHover={true} comment={comment()} isShort={true} />
|
<CommentDate showOnHover={true} comment={props.comment} isShort={true} />
|
||||||
<CommentRatingControl comment={comment()} />
|
<CommentRatingControl comment={props.comment} />
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
<div class={styles.commentBody}>
|
<div class={styles.commentBody}>
|
||||||
<Show when={editMode()} fallback={<div innerHTML={body()} />}>
|
<Show when={editMode()} fallback={<div innerHTML={body()} />}>
|
||||||
<Suspense fallback={<p>{t('Loading')}</p>}>
|
<Suspense fallback={<p>{t('Loading')}</p>}>
|
||||||
<SimplifiedEditor
|
<SimplifiedEditor
|
||||||
initialContent={comment().body}
|
initialContent={props.comment.body}
|
||||||
submitButtonText={t('Save')}
|
submitButtonText={t('Save')}
|
||||||
quoteEnabled={true}
|
quoteEnabled={true}
|
||||||
imageEnabled={true}
|
imageEnabled={true}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { For, Show, createEffect, createSignal, on, onMount } from 'solid-js'
|
||||||
import { useFollowing } from '../../context/following'
|
import { useFollowing } from '../../context/following'
|
||||||
import { useLocalize } from '../../context/localize'
|
import { useLocalize } from '../../context/localize'
|
||||||
import { apiClient } from '../../graphql/client/core'
|
import { apiClient } from '../../graphql/client/core'
|
||||||
|
import { Author } from '../../graphql/schema/core.gen'
|
||||||
import { setAuthorsByFollowers, setAuthorsByShouts, useAuthorsStore } from '../../stores/zine/authors'
|
import { setAuthorsByFollowers, setAuthorsByShouts, useAuthorsStore } from '../../stores/zine/authors'
|
||||||
import { AuthorBadge } from '../Author/AuthorBadge'
|
import { AuthorBadge } from '../Author/AuthorBadge'
|
||||||
import { InlineLoader } from '../InlineLoader'
|
import { InlineLoader } from '../InlineLoader'
|
||||||
|
@ -17,6 +18,7 @@ type Props = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const PAGE_SIZE = 20
|
const PAGE_SIZE = 20
|
||||||
|
|
||||||
export const AuthorsList = (props: Props) => {
|
export const AuthorsList = (props: Props) => {
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
const { isOwnerSubscribed } = useFollowing()
|
const { isOwnerSubscribed } = useFollowing()
|
||||||
|
@ -27,8 +29,6 @@ export const AuthorsList = (props: Props) => {
|
||||||
|
|
||||||
const fetchAuthors = async (queryType: Props['query'], page: number) => {
|
const fetchAuthors = async (queryType: Props['query'], page: number) => {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
console.log('!!! AAA:')
|
|
||||||
const offset = PAGE_SIZE * page
|
const offset = PAGE_SIZE * page
|
||||||
const result = await apiClient.loadAuthorsBy({
|
const result = await apiClient.loadAuthorsBy({
|
||||||
by: { order: queryType },
|
by: { order: queryType },
|
||||||
|
@ -42,7 +42,6 @@ export const AuthorsList = (props: Props) => {
|
||||||
setAuthorsByFollowers((prev) => [...prev, ...result])
|
setAuthorsByFollowers((prev) => [...prev, ...result])
|
||||||
}
|
}
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadMoreAuthors = () => {
|
const loadMoreAuthors = () => {
|
||||||
|
@ -57,7 +56,7 @@ export const AuthorsList = (props: Props) => {
|
||||||
() => props.query,
|
() => props.query,
|
||||||
(query) => {
|
(query) => {
|
||||||
const authorsList = query === 'shouts' ? authorsByShouts() : authorsByFollowers()
|
const authorsList = query === 'shouts' ? authorsByShouts() : authorsByFollowers()
|
||||||
if (authorsList.length === 0 || currentPage()[query] === 0) {
|
if (authorsList.length === 0 && currentPage()[query] === 0) {
|
||||||
setCurrentPage((prev) => ({ ...prev, [query]: 0 }))
|
setCurrentPage((prev) => ({ ...prev, [query]: 0 }))
|
||||||
fetchAuthors(query, 0).then(() => setCurrentPage((prev) => ({ ...prev, [query]: 1 })))
|
fetchAuthors(query, 0).then(() => setCurrentPage((prev) => ({ ...prev, [query]: 1 })))
|
||||||
}
|
}
|
||||||
|
@ -75,7 +74,7 @@ export const AuthorsList = (props: Props) => {
|
||||||
// })
|
// })
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
setAllLoaded(authorsByShouts().length === authorsList.length)
|
setAllLoaded(props.allAuthorsLength === authorsList.length)
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -53,7 +53,6 @@ export const RegisterForm = () => {
|
||||||
|
|
||||||
const handleSubmit = async (event: Event) => {
|
const handleSubmit = async (event: Event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
if (passwordError()) {
|
if (passwordError()) {
|
||||||
setValidationErrors((errors) => ({ ...errors, password: passwordError() }))
|
setValidationErrors((errors) => ({ ...errors, password: passwordError() }))
|
||||||
} else {
|
} else {
|
||||||
|
@ -102,7 +101,7 @@ export const RegisterForm = () => {
|
||||||
redirect_uri: window.location.origin,
|
redirect_uri: window.location.origin,
|
||||||
}
|
}
|
||||||
const { errors } = await signUp(opts)
|
const { errors } = await signUp(opts)
|
||||||
if (errors) return
|
if (errors.length > 0) return
|
||||||
setIsSuccess(true)
|
setIsSuccess(true)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
@ -134,7 +133,6 @@ export const RegisterForm = () => {
|
||||||
),
|
),
|
||||||
}))
|
}))
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'verified':
|
case 'verified':
|
||||||
setValidationErrors((prev) => ({
|
setValidationErrors((prev) => ({
|
||||||
email: (
|
email: (
|
||||||
|
|
|
@ -96,7 +96,6 @@ export const SendResetLinkForm = () => {
|
||||||
placeholder={t('Email')}
|
placeholder={t('Email')}
|
||||||
onInput={(event) => handleEmailInput(event.currentTarget.value)}
|
onInput={(event) => handleEmailInput(event.currentTarget.value)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<label for="email">{t('Email')}</label>
|
<label for="email">{t('Email')}</label>
|
||||||
<Show when={isUserNotFound()}>
|
<Show when={isUserNotFound()}>
|
||||||
<div class={styles.validationError}>
|
<div class={styles.validationError}>
|
||||||
|
|
|
@ -122,7 +122,13 @@ export const SessionProvider = (props: {
|
||||||
m: 'auth',
|
m: 'auth',
|
||||||
access_token,
|
access_token,
|
||||||
})
|
})
|
||||||
else if (token) changeSearchParams({ mode: 'change-password', modal: 'auth', token })
|
else if (token) {
|
||||||
|
changeSearchParams({
|
||||||
|
mode: 'change-password',
|
||||||
|
m: 'auth',
|
||||||
|
token,
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// load
|
// load
|
||||||
|
@ -207,7 +213,6 @@ export const SessionProvider = (props: {
|
||||||
if (session()) {
|
if (session()) {
|
||||||
const token = session()?.access_token
|
const token = session()?.access_token
|
||||||
if (token) {
|
if (token) {
|
||||||
// console.log('[context.session] token observer got token', token)
|
|
||||||
if (!inboxClient.private) {
|
if (!inboxClient.private) {
|
||||||
apiClient.connect(token)
|
apiClient.connect(token)
|
||||||
notifierClient.connect(token)
|
notifierClient.connect(token)
|
||||||
|
@ -333,7 +338,6 @@ export const SessionProvider = (props: {
|
||||||
const response = await authorizer().graphqlQuery({
|
const response = await authorizer().graphqlQuery({
|
||||||
query: `query { is_registered(email: "${email}") { message }}`,
|
query: `query { is_registered(email: "${email}") { message }}`,
|
||||||
})
|
})
|
||||||
// console.log(response)
|
|
||||||
return response?.data?.is_registered?.message
|
return response?.data?.is_registered?.message
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
|
|
|
@ -25,6 +25,7 @@ export type PageProps = {
|
||||||
export type RootSearchParams = {
|
export type RootSearchParams = {
|
||||||
m: string // modal
|
m: string // modal
|
||||||
lang: string
|
lang: string
|
||||||
|
token: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LayoutType = 'article' | 'audio' | 'video' | 'image' | 'literature'
|
export type LayoutType = 'article' | 'audio' | 'video' | 'image' | 'literature'
|
||||||
|
|
|
@ -153,7 +153,7 @@ export const useRouter = <TSearchParams extends Record<string, string> = Record<
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearSearchParams = (replace = false) => {
|
const clearSearchParams = (replace = false) => {
|
||||||
// searchParamsStore.open({}, replace)
|
searchParamsStore.open({}, replace)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user