schema-updates
This commit is contained in:
parent
1159adc6ff
commit
7b3ab33481
|
@ -18,7 +18,7 @@ type Props = {
|
|||
|
||||
export const CommentRatingControl = (props: Props) => {
|
||||
const { t } = useLocalize()
|
||||
const { user } = useSession()
|
||||
const { author } = useSession()
|
||||
const {
|
||||
actions: { showSnackbar },
|
||||
} = useSnackbar()
|
||||
|
@ -31,13 +31,13 @@ export const CommentRatingControl = (props: Props) => {
|
|||
Object.values(reactionEntities).some(
|
||||
(r) =>
|
||||
r.kind === reactionKind &&
|
||||
r.created_by.slug === user()?.slug &&
|
||||
r.created_by.slug === author()?.slug &&
|
||||
r.shout.id === props.comment.shout.id &&
|
||||
r.reply_to === props.comment.id,
|
||||
)
|
||||
const isUpvoted = createMemo(() => checkReaction(ReactionKind.Like))
|
||||
const isDownvoted = createMemo(() => checkReaction(ReactionKind.Dislike))
|
||||
const canVote = createMemo(() => user()?.slug !== props.comment.created_by.slug)
|
||||
const canVote = createMemo(() => author()?.slug !== props.comment.created_by.slug)
|
||||
|
||||
const commentRatingReactions = createMemo(() =>
|
||||
Object.values(reactionEntities).filter(
|
||||
|
@ -52,7 +52,7 @@ export const CommentRatingControl = (props: Props) => {
|
|||
const reactionToDelete = Object.values(reactionEntities).find(
|
||||
(r) =>
|
||||
r.kind === reactionKind &&
|
||||
r.created_by.slug === user()?.slug &&
|
||||
r.created_by.slug === author()?.slug &&
|
||||
r.shout.id === props.comment.shout.id &&
|
||||
r.reply_to === props.comment.id,
|
||||
)
|
||||
|
@ -86,7 +86,7 @@ export const CommentRatingControl = (props: Props) => {
|
|||
<div class={styles.commentRating}>
|
||||
<button
|
||||
role="button"
|
||||
disabled={!canVote() || !user()}
|
||||
disabled={!canVote() || !author()}
|
||||
onClick={() => handleRatingChange(true)}
|
||||
class={clsx(styles.commentRatingControl, styles.commentRatingControlUp, {
|
||||
[styles.voted]: isUpvoted(),
|
||||
|
@ -112,7 +112,7 @@ export const CommentRatingControl = (props: Props) => {
|
|||
</Popup>
|
||||
<button
|
||||
role="button"
|
||||
disabled={!canVote() || !user()}
|
||||
disabled={!canVote() || !author()}
|
||||
onClick={() => handleRatingChange(false)}
|
||||
class={clsx(styles.commentRatingControl, styles.commentRatingControlDown, {
|
||||
[styles.voted]: isDownvoted(),
|
||||
|
|
|
@ -43,7 +43,7 @@ type Props = {
|
|||
}
|
||||
|
||||
export const CommentsTree = (props: Props) => {
|
||||
const { session } = useSession()
|
||||
const { author } = useSession()
|
||||
const { t } = useLocalize()
|
||||
const [commentsOrder, setCommentsOrder] = createSignal<CommentsOrder>('createdAt')
|
||||
const [newReactions, setNewReactions] = createSignal<Reaction[]>([])
|
||||
|
@ -85,7 +85,7 @@ export const CommentsTree = (props: Props) => {
|
|||
setCookie()
|
||||
} else if (currentDate.getTime() > dateFromLocalStorage) {
|
||||
const newComments = comments().filter((c) => {
|
||||
if (c.reply_to || c.created_by.slug === session()?.user.slug) {
|
||||
if (c.reply_to || c.created_by.slug === author()?.slug) {
|
||||
return
|
||||
}
|
||||
const created = c.created_at
|
||||
|
|
|
@ -61,7 +61,7 @@ export const FullArticle = (props: Props) => {
|
|||
|
||||
const { t, formatDate } = useLocalize()
|
||||
const {
|
||||
user,
|
||||
author,
|
||||
isAuthenticated,
|
||||
actions: { requireAuthentication },
|
||||
} = useSession()
|
||||
|
@ -72,7 +72,7 @@ export const FullArticle = (props: Props) => {
|
|||
|
||||
const mainTopic = createMemo(() => (props.article.topics.length > 0 ? props.article.topics[0] : null))
|
||||
|
||||
const canEdit = () => props.article.authors?.some((a) => a.slug === user()?.slug)
|
||||
const canEdit = () => props.article.authors?.some((a) => a.slug === author()?.slug)
|
||||
|
||||
const handleBookmarkButtonClick = (ev) => {
|
||||
requireAuthentication(() => {
|
||||
|
|
|
@ -20,7 +20,7 @@ interface ShoutRatingControlProps {
|
|||
export const ShoutRatingControl = (props: ShoutRatingControlProps) => {
|
||||
const { t } = useLocalize()
|
||||
const {
|
||||
user,
|
||||
author,
|
||||
actions: { requireAuthentication },
|
||||
} = useSession()
|
||||
|
||||
|
@ -33,7 +33,7 @@ export const ShoutRatingControl = (props: ShoutRatingControlProps) => {
|
|||
Object.values(reactionEntities).some(
|
||||
(r) =>
|
||||
r.kind === reactionKind &&
|
||||
r.created_by.slug === user()?.slug &&
|
||||
r.created_by.slug === author()?.slug &&
|
||||
r.shout.id === props.shout.id &&
|
||||
!r.reply_to,
|
||||
)
|
||||
|
@ -55,7 +55,7 @@ export const ShoutRatingControl = (props: ShoutRatingControlProps) => {
|
|||
const reactionToDelete = Object.values(reactionEntities).find(
|
||||
(r) =>
|
||||
r.kind === reactionKind &&
|
||||
r.created_by.slug === user()?.slug &&
|
||||
r.created_by.slug === author()?.slug &&
|
||||
r.shout.id === props.shout.id &&
|
||||
!r.reply_to,
|
||||
)
|
||||
|
|
|
@ -73,7 +73,7 @@ const providers: Record<string, HocuspocusProvider> = {}
|
|||
|
||||
export const Editor = (props: Props) => {
|
||||
const { t } = useLocalize()
|
||||
const { user } = useSession()
|
||||
const { author } = useSession()
|
||||
|
||||
const [isCommonMarkup, setIsCommonMarkup] = createSignal(false)
|
||||
const [shouldShowTextBubbleMenu, setShouldShowTextBubbleMenu] = createSignal(false)
|
||||
|
@ -234,8 +234,8 @@ export const Editor = (props: Props) => {
|
|||
CollaborationCursor.configure({
|
||||
provider: providers[docName],
|
||||
user: {
|
||||
name: user().name,
|
||||
color: uniqolor(user().slug).color,
|
||||
name: author().name,
|
||||
color: uniqolor(author().slug).color,
|
||||
},
|
||||
}),
|
||||
Placeholder.configure({
|
||||
|
|
|
@ -85,7 +85,7 @@ const getTitleAndSubtitle = (
|
|||
|
||||
export const ArticleCard = (props: ArticleCardProps) => {
|
||||
const { t, lang, formatDate } = useLocalize()
|
||||
const { user } = useSession()
|
||||
const { author } = useSession()
|
||||
const mainTopic = props.article.topics[0]
|
||||
|
||||
const formattedDate = createMemo<string>(() => {
|
||||
|
@ -94,7 +94,8 @@ export const ArticleCard = (props: ArticleCardProps) => {
|
|||
|
||||
const { title, subtitle } = getTitleAndSubtitle(props.article)
|
||||
|
||||
const canEdit = () => props.article.authors?.some((a) => a.slug === user()?.slug)
|
||||
const canEdit = () =>
|
||||
props.article.authors?.some((a) => a.slug === author()?.slug) || props.article.created_by == author().id
|
||||
|
||||
const { changeSearchParam } = useRouter()
|
||||
const scrollToComments = (event) => {
|
||||
|
|
|
@ -19,15 +19,9 @@ import { ConfirmModal } from '../ConfirmModal'
|
|||
import { HeaderAuth } from '../HeaderAuth'
|
||||
import { Modal } from '../Modal'
|
||||
import { Snackbar } from '../Snackbar'
|
||||
|
||||
import { Link } from './Link'
|
||||
|
||||
import styles from './Header.module.scss'
|
||||
import { apiClient } from '../../../utils/apiClient'
|
||||
import { RANDOM_TOPICS_COUNT } from '../../Views/Home'
|
||||
import { Link } from './Link'
|
||||
import { Subscribe } from '../../_shared/Subscribe'
|
||||
import { SearchModal } from '../SearchModal/SearchModal'
|
||||
import styles from './Header.module.scss'
|
||||
|
||||
type Props = {
|
||||
title?: string
|
||||
|
|
|
@ -9,7 +9,15 @@ import { Reaction, ReactionBy, ReactionInput, ReactionKind } from '../graphql/sc
|
|||
type ReactionsContextType = {
|
||||
reactionEntities: Record<number, Reaction>
|
||||
actions: {
|
||||
loadReactionsBy: ({ by, limit }: { by: ReactionBy; limit?: number }) => Promise<Reaction[]>
|
||||
loadReactionsBy: ({
|
||||
by,
|
||||
limit,
|
||||
offset,
|
||||
}: {
|
||||
by: ReactionBy
|
||||
limit?: number
|
||||
offset?: number
|
||||
}) => Promise<Reaction[]>
|
||||
createReaction: (reaction: ReactionInput) => Promise<void>
|
||||
updateReaction: (id: number, reaction: ReactionInput) => Promise<void>
|
||||
deleteReaction: (id: number) => Promise<void>
|
||||
|
@ -28,11 +36,13 @@ export const ReactionsProvider = (props: { children: JSX.Element }) => {
|
|||
const loadReactionsBy = async ({
|
||||
by,
|
||||
limit,
|
||||
offset,
|
||||
}: {
|
||||
by: ReactionBy
|
||||
limit?: number
|
||||
offset?: number
|
||||
}): Promise<Reaction[]> => {
|
||||
const reactions = await apiClient.getReactionsBy({ by, limit })
|
||||
const reactions = await apiClient.getReactionsBy({ by, limit, offset })
|
||||
const newReactionEntities = reactions.reduce((acc, reaction) => {
|
||||
acc[reaction.id] = reaction
|
||||
return acc
|
||||
|
|
|
@ -183,9 +183,9 @@ export const apiClient = {
|
|||
return resp.data.load_shouts_feed
|
||||
},
|
||||
|
||||
getReactionsBy: async ({ by, limit }: { by: ReactionBy; limit?: number }) => {
|
||||
getReactionsBy: async ({ by, limit, offset }: { by: ReactionBy; limit?: number; offset?: number }) => {
|
||||
const resp = await publicGraphQLClient
|
||||
.query(reactionsLoadBy, { by, limit: limit ?? 1000, offset: 0 })
|
||||
.query(reactionsLoadBy, { by, limit: limit ?? 1000, offset: offset ?? 0 })
|
||||
.toPromise()
|
||||
return resp.data.load_reactions_by
|
||||
},
|
||||
|
|
|
@ -14,8 +14,21 @@ export default gql`
|
|||
cover
|
||||
body
|
||||
media
|
||||
created_by {
|
||||
id
|
||||
name
|
||||
slug
|
||||
pic
|
||||
created_at
|
||||
}
|
||||
updated_by {
|
||||
id
|
||||
name
|
||||
slug
|
||||
pic
|
||||
created_at
|
||||
}
|
||||
# community
|
||||
# mainTopic
|
||||
topics {
|
||||
id
|
||||
title
|
||||
|
@ -35,6 +48,7 @@ export default gql`
|
|||
created_at
|
||||
}
|
||||
created_at
|
||||
updated_at
|
||||
published_at
|
||||
stat {
|
||||
viewed
|
||||
|
|
|
@ -12,8 +12,13 @@ export default gql`
|
|||
layout
|
||||
cover
|
||||
lead
|
||||
# community
|
||||
# mainTopic
|
||||
created_by {
|
||||
id
|
||||
name
|
||||
slug
|
||||
pic
|
||||
created_at
|
||||
}
|
||||
topics {
|
||||
id
|
||||
title
|
||||
|
|
|
@ -10,7 +10,13 @@ export default gql`
|
|||
layout
|
||||
cover
|
||||
# community
|
||||
# mainTopic
|
||||
created_by {
|
||||
id
|
||||
name
|
||||
slug
|
||||
pic
|
||||
created_at
|
||||
}
|
||||
media
|
||||
topics {
|
||||
id
|
||||
|
|
|
@ -10,7 +10,13 @@ export default gql`
|
|||
layout
|
||||
cover
|
||||
# community
|
||||
# mainTopic
|
||||
created_by {
|
||||
id
|
||||
name
|
||||
slug
|
||||
pic
|
||||
created_at
|
||||
}
|
||||
topics {
|
||||
id
|
||||
title
|
||||
|
|
|
@ -9,7 +9,13 @@ export default gql`
|
|||
slug
|
||||
cover
|
||||
# community
|
||||
# mainTopic
|
||||
created_by {
|
||||
id
|
||||
name
|
||||
slug
|
||||
pic
|
||||
created_at
|
||||
}
|
||||
topics {
|
||||
# id
|
||||
title
|
||||
|
|
|
@ -15,6 +15,13 @@ export default gql`
|
|||
body
|
||||
slug
|
||||
}
|
||||
created_by {
|
||||
id
|
||||
name
|
||||
slug
|
||||
pic
|
||||
created_at
|
||||
}
|
||||
authors {
|
||||
id
|
||||
name
|
||||
|
|
Loading…
Reference in New Issue
Block a user