diff --git a/src/core/client/stream/components/Comment/IndentedComment.css b/src/core/client/stream/components/Comment/IndentedComment.css new file mode 100644 index 000000000..ff0a0fa5f --- /dev/null +++ b/src/core/client/stream/components/Comment/IndentedComment.css @@ -0,0 +1,5 @@ +.blur { + filter: blur(2px); + user-select: none; + pointer-events: none; +} diff --git a/src/core/client/stream/components/Comment/IndentedComment.tsx b/src/core/client/stream/components/Comment/IndentedComment.tsx index 2460f905b..157689517 100644 --- a/src/core/client/stream/components/Comment/IndentedComment.tsx +++ b/src/core/client/stream/components/Comment/IndentedComment.tsx @@ -1,20 +1,25 @@ +import cn from "classnames"; import React, { StatelessComponent } from "react"; import { PropTypesOf } from "talk-framework/types"; import Indent from "../Indent"; import Comment from "./Comment"; +import * as styles from "./IndentedComment.css"; export interface IndentedCommentProps extends PropTypesOf { indentLevel?: number; + blur?: boolean; } const IndentedComment: StatelessComponent = props => { const { indentLevel, ...rest } = props; const CommentElement = ; - const CommentwithIndent = - (indentLevel && {CommentElement}) || - CommentElement; + const CommentwithIndent = ( + + {CommentElement} + + ); return CommentwithIndent; }; diff --git a/src/core/client/stream/components/Comment/__snapshots__/IndentedComment.spec.tsx.snap b/src/core/client/stream/components/Comment/__snapshots__/IndentedComment.spec.tsx.snap index d264e4050..daaa79aca 100644 --- a/src/core/client/stream/components/Comment/__snapshots__/IndentedComment.spec.tsx.snap +++ b/src/core/client/stream/components/Comment/__snapshots__/IndentedComment.spec.tsx.snap @@ -2,6 +2,7 @@ exports[`renders correctly 1`] = ` = props => { return (
{ editing: { editableUntil: "1995-12-17T03:24:30.000Z", }, + pending: false, }, indentLevel: 1, showAuthPopup: noop as any, @@ -51,6 +52,7 @@ it("renders body only", () => { editing: { editableUntil: "1995-12-17T03:24:30.000Z", }, + pending: false, }, indentLevel: 1, showAuthPopup: noop as any, diff --git a/src/core/client/stream/containers/CommentContainer.tsx b/src/core/client/stream/containers/CommentContainer.tsx index df61c3f9e..13797018c 100644 --- a/src/core/client/stream/containers/CommentContainer.tsx +++ b/src/core/client/stream/containers/CommentContainer.tsx @@ -112,6 +112,7 @@ export class CommentContainer extends Component { author={comment.author} body={comment.body} createdAt={comment.createdAt} + blur={comment.pending || false} topBarRight={ (editable && ( @@ -174,6 +175,7 @@ const enhanced = withShowAuthPopupMutation( editing { editableUntil } + pending ...ReplyCommentFormContainer_comment ...EditCommentFormContainer_comment } diff --git a/src/core/client/stream/containers/__snapshots__/CommentContainer.spec.tsx.snap b/src/core/client/stream/containers/__snapshots__/CommentContainer.spec.tsx.snap index 9ad26125f..c58185c5b 100644 --- a/src/core/client/stream/containers/__snapshots__/CommentContainer.spec.tsx.snap +++ b/src/core/client/stream/containers/__snapshots__/CommentContainer.spec.tsx.snap @@ -8,6 +8,7 @@ exports[`renders body only 1`] = ` "username": null, } } + blur={false} body="Woof" createdAt="1995-12-17T03:24:00.000Z" footer={ @@ -35,6 +36,7 @@ exports[`renders username and body 1`] = ` "username": "Marvin", } } + blur={false} body="Woof" createdAt="1995-12-17T03:24:00.000Z" footer={ diff --git a/src/core/client/stream/local/local.graphql b/src/core/client/stream/local/local.graphql index 9c2585ebf..9e04c476a 100644 --- a/src/core/client/stream/local/local.graphql +++ b/src/core/client/stream/local/local.graphql @@ -15,6 +15,10 @@ type AuthPopup { view: View } +extend type Comment { + pending: Boolean +} + type Local { network: Network! assetID: String diff --git a/src/core/client/stream/mutations/CreateCommentMutation.ts b/src/core/client/stream/mutations/CreateCommentMutation.ts index 958ad9acc..b858f04e2 100644 --- a/src/core/client/stream/mutations/CreateCommentMutation.ts +++ b/src/core/client/stream/mutations/CreateCommentMutation.ts @@ -72,6 +72,7 @@ function commit( ) { const me = getMe(environment)!; const currentDate = new Date().toISOString(); + const id = uuidGenerator(); return commitMutationPromiseNormalized(environment, { mutation, variables: { @@ -85,7 +86,7 @@ function commit( edge: { cursor: currentDate, node: { - id: uuidGenerator(), + id, createdAt: currentDate, author: { id: me.id, @@ -100,6 +101,9 @@ function commit( clientMutationId: (clientMutationId++).toString(), }, } as any, // TODO: (cvle) generated types should contain one for the optimistic response. + optimisticUpdater: store => { + store.get(id)!.setValue(true, "pending"); + }, configs: getConfig(input), }); } diff --git a/src/core/client/stream/test/__snapshots__/editComment.spec.tsx.snap b/src/core/client/stream/test/__snapshots__/editComment.spec.tsx.snap index 07b6f3c19..32b7681fa 100644 --- a/src/core/client/stream/test/__snapshots__/editComment.spec.tsx.snap +++ b/src/core/client/stream/test/__snapshots__/editComment.spec.tsx.snap @@ -188,32 +188,62 @@ exports[`cancel edit: edit canceled 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
+
+ +
-
+
+
-
-
- -
- - Lukas - - + + Lukas + + +
-
-
-
- + +
@@ -672,56 +680,60 @@ exports[`edit a comment: edit form 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Lukas - - + + Lukas + + +
-
-
-
- + +
@@ -1083,56 +1095,60 @@ exports[`edit a comment: optimistic response 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Lukas - - + + Lukas + + +
-
-
-
- + +
@@ -1329,32 +1345,62 @@ exports[`edit a comment: render stream 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
+
+ +
-
+
+
-
-
- -
- - Lukas - - + + Lukas + + +
-
-
-
- + +
@@ -1648,32 +1672,62 @@ exports[`edit a comment: server response 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
+
+ +
-
+
+
-
-
- -
- - Lukas - - + + Lukas + + +
-
-
-
- + +
@@ -1967,32 +1999,62 @@ exports[`shows expiry message: edit form closed 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
+
+ +
-
+
+
-
-
- -
- - Lukas - - + + Lukas + + +
-
-
-
- + +
@@ -2428,56 +2468,60 @@ exports[`shows expiry message: edit time expired 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Lukas - - + + Lukas + + +
-
-
-
- + +
diff --git a/src/core/client/stream/test/__snapshots__/loadMore.spec.tsx.snap b/src/core/client/stream/test/__snapshots__/loadMore.spec.tsx.snap index 27964d7c7..2d039a849 100644 --- a/src/core/client/stream/test/__snapshots__/loadMore.spec.tsx.snap +++ b/src/core/client/stream/test/__snapshots__/loadMore.spec.tsx.snap @@ -149,56 +149,60 @@ exports[`loads more comments 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
-
- + +
@@ -206,56 +210,60 @@ exports[`loads more comments 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Lukas - - + + Lukas + + +
-
-
-
- + +
@@ -263,56 +271,60 @@ exports[`loads more comments 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Isabelle - - + + Isabelle + + +
-
-
-
- + +
@@ -470,56 +482,60 @@ exports[`renders comment stream 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
-
- + +
@@ -527,56 +543,60 @@ exports[`renders comment stream 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Lukas - - + + Lukas + + +
-
-
-
- + +
diff --git a/src/core/client/stream/test/__snapshots__/permalinkView.spec.tsx.snap b/src/core/client/stream/test/__snapshots__/permalinkView.spec.tsx.snap index a21e1148b..a3598699e 100644 --- a/src/core/client/stream/test/__snapshots__/permalinkView.spec.tsx.snap +++ b/src/core/client/stream/test/__snapshots__/permalinkView.spec.tsx.snap @@ -24,56 +24,60 @@ exports[`renders permalink view 1`] = ` Show all comments
- - Markus - - + + Markus + + +
-
-
-
- + +
@@ -229,56 +233,60 @@ exports[`show all comments 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
-
- + +
diff --git a/src/core/client/stream/test/__snapshots__/permalinkViewCommentNotFound.spec.tsx.snap b/src/core/client/stream/test/__snapshots__/permalinkViewCommentNotFound.spec.tsx.snap index f5ac0cf10..e4ccc295a 100644 --- a/src/core/client/stream/test/__snapshots__/permalinkViewCommentNotFound.spec.tsx.snap +++ b/src/core/client/stream/test/__snapshots__/permalinkViewCommentNotFound.spec.tsx.snap @@ -181,56 +181,60 @@ exports[`show all comments 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
-
- + +
diff --git a/src/core/client/stream/test/__snapshots__/postComment.spec.tsx.snap b/src/core/client/stream/test/__snapshots__/postComment.spec.tsx.snap index 0c0129082..4ccf8d58d 100644 --- a/src/core/client/stream/test/__snapshots__/postComment.spec.tsx.snap +++ b/src/core/client/stream/test/__snapshots__/postComment.spec.tsx.snap @@ -182,32 +182,62 @@ exports[`post a comment: optimistic response 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
+
+ +
-
+
Hello world!", + } + } + /> +
+
+
+
+
Hello world!", - } - } - /> -
- +
+ + Markus + + +
+
+
+
+ +
@@ -255,113 +320,60 @@ exports[`post a comment: optimistic response 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Lukas + + +
-
-
-
- -
-
-
-
-
-
- - Lukas - - -
-
-
-
- + +
@@ -558,56 +570,60 @@ exports[`post a comment: server response 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
Hello world! (from server)", +
Hello world! (from server)", + } } - } - /> -
- + +
@@ -615,56 +631,60 @@ exports[`post a comment: server response 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
-
- + +
@@ -672,56 +692,60 @@ exports[`post a comment: server response 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Lukas - - + + Lukas + + +
-
-
-
- + +
@@ -918,56 +942,60 @@ exports[`renders comment stream 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
-
- + +
@@ -975,56 +1003,60 @@ exports[`renders comment stream 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Lukas - - + + Lukas + + +
-
-
-
- + +
diff --git a/src/core/client/stream/test/__snapshots__/postReply.spec.tsx.snap b/src/core/client/stream/test/__snapshots__/postReply.spec.tsx.snap index ad6177fc0..b19964019 100644 --- a/src/core/client/stream/test/__snapshots__/postReply.spec.tsx.snap +++ b/src/core/client/stream/test/__snapshots__/postReply.spec.tsx.snap @@ -188,56 +188,60 @@ exports[`post a reply: open reply form 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
-
- + +
- - Lukas - - + + Lukas + + +
-
-
-
- + +
@@ -618,56 +626,60 @@ exports[`post a reply: optimistic response 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
-
- + +
- - Lukas - - + + Lukas + + +
-
-
-
- + +
@@ -1121,56 +1137,60 @@ exports[`post a reply: server response 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
-
- + +
- - Lukas - - + + Lukas + + +
-
-
-
- + +
@@ -1487,56 +1511,60 @@ exports[`renders comment stream 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
-
- + +
@@ -1544,56 +1572,60 @@ exports[`renders comment stream 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Lukas - - + + Lukas + + +
-
-
-
- + +
diff --git a/src/core/client/stream/test/__snapshots__/renderReplies.spec.tsx.snap b/src/core/client/stream/test/__snapshots__/renderReplies.spec.tsx.snap index 3ceec7207..68830fcce 100644 --- a/src/core/client/stream/test/__snapshots__/renderReplies.spec.tsx.snap +++ b/src/core/client/stream/test/__snapshots__/renderReplies.spec.tsx.snap @@ -149,56 +149,60 @@ exports[`renders comment stream 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
-
- + +
@@ -206,56 +210,60 @@ exports[`renders comment stream 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
-
- + +
- - Markus - - + + Markus + + +
-
-
-
- + +
@@ -206,56 +210,60 @@ exports[`renders comment stream 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Lukas - - + + Lukas + + +
-
-
-
- + +
diff --git a/src/core/client/stream/test/__snapshots__/showAllReplies.spec.tsx.snap b/src/core/client/stream/test/__snapshots__/showAllReplies.spec.tsx.snap index 94cacbaf6..caf62a93a 100644 --- a/src/core/client/stream/test/__snapshots__/showAllReplies.spec.tsx.snap +++ b/src/core/client/stream/test/__snapshots__/showAllReplies.spec.tsx.snap @@ -149,56 +149,60 @@ exports[`renders comment stream 1`] = ` className="HorizontalGutter-root HorizontalGutter-full" >
- - Markus - - + + Markus + + +
-
-
-
- + +
- - Markus - - + + Markus + + +
-
-
-
- + +