[146] resolve conversation

This commit is contained in:
ilya-bkv 2023-03-09 19:19:28 +03:00
parent 4389124912
commit 06e68fca4a
4 changed files with 12 additions and 10 deletions

View File

@ -97,7 +97,6 @@ export const Comment = (props: Props) => {
return ( return (
<li class={clsx(styles.comment, { [styles.isNew]: !isCommentAuthor() && createdAt > props.lastSeen })}> <li class={clsx(styles.comment, { [styles.isNew]: !isCommentAuthor() && createdAt > props.lastSeen })}>
<Show when={!!body()}> <Show when={!!body()}>
<div style={{ color: 'red' }}>{comment().id}</div>
<div class={styles.commentContent}> <div class={styles.commentContent}>
<Show <Show
when={!props.compact} when={!props.compact}

View File

@ -30,7 +30,8 @@ export const CommentRatingControl = (props: Props) => {
) )
const isUpvoted = createMemo(() => checkReaction(ReactionKind.Like)) const isUpvoted = createMemo(() => checkReaction(ReactionKind.Like))
const isDownvoted = createMemo(() => checkReaction(ReactionKind.Dislike)) const isDownvoted = createMemo(() => checkReaction(ReactionKind.Dislike))
const canVote = userSlug() !== props.comment.createdBy.slug const canVote = createMemo(() => userSlug() !== props.comment.createdBy.slug)
const shoutRatingReactions = createMemo(() => const shoutRatingReactions = createMemo(() =>
Object.values(reactionEntities).filter( Object.values(reactionEntities).filter(
(r) => (r) =>
@ -56,7 +57,6 @@ export const CommentRatingControl = (props: Props) => {
} else if (isDownvoted()) { } else if (isDownvoted()) {
await deleteCommentReaction(ReactionKind.Dislike) await deleteCommentReaction(ReactionKind.Dislike)
} else { } else {
console.log('!!! createReaction:')
await createReaction({ await createReaction({
kind: isUpvote ? ReactionKind.Like : ReactionKind.Dislike, kind: isUpvote ? ReactionKind.Like : ReactionKind.Dislike,
shout: props.comment.shout.id, shout: props.comment.shout.id,
@ -72,8 +72,11 @@ export const CommentRatingControl = (props: Props) => {
return ( return (
<div class={styles.commentRating}> <div class={styles.commentRating}>
{!canVote()}
<button <button
onClick={() => canVote && handleRatingChange(true)} role="button"
disabled={!canVote() || !userSlug()}
onClick={() => handleRatingChange(true)}
class={clsx(styles.commentRatingControl, styles.commentRatingControlUp, { class={clsx(styles.commentRatingControl, styles.commentRatingControlUp, {
[styles.voted]: isUpvoted() [styles.voted]: isUpvoted()
})} })}
@ -102,7 +105,9 @@ export const CommentRatingControl = (props: Props) => {
</ul> </ul>
</Popup> </Popup>
<button <button
onClick={() => canVote && handleRatingChange(false)} role="button"
disabled={!canVote() || !userSlug()}
onClick={() => handleRatingChange(false)}
class={clsx(styles.commentRatingControl, styles.commentRatingControlDown, { class={clsx(styles.commentRatingControl, styles.commentRatingControlDown, {
[styles.voted]: isDownvoted() [styles.voted]: isDownvoted()
})} })}

3
src/utils/clone.ts Normal file
View File

@ -0,0 +1,3 @@
// debug nested objects console.log('message', clone(obj))
export const clone = <T>(obj: T) => JSON.parse(JSON.stringify(obj))

View File

@ -1,5 +0,0 @@
export const jsonParse = <T>(obj: T) => JSON.parse(JSON.stringify(obj))
export const jsonParseLog = <T>(msg: string, obj: T) => {
console.log(`${msg}: `, JSON.parse(JSON.stringify(obj)))
}