mirror of
https://github.com/wassname/talk.git
synced 2026-07-02 07:39:44 +08:00
Optimistic Responses updated
This commit is contained in:
@@ -29,7 +29,6 @@ let clientMutationId = 0;
|
||||
|
||||
function commit(environment: Environment, input: CreateCommentReactionInput) {
|
||||
const source = environment.getStore().getSource();
|
||||
|
||||
const currentCount = source.get(
|
||||
source.get(source.get(input.commentID)!.actionCounts.__ref)!.reaction.__ref
|
||||
)!.total;
|
||||
@@ -49,7 +48,7 @@ function commit(environment: Environment, input: CreateCommentReactionInput) {
|
||||
myActionPresence: {
|
||||
reaction: true,
|
||||
},
|
||||
actionCounts: currentCount,
|
||||
actionCounts: currentCount + 1,
|
||||
},
|
||||
clientMutationId: (clientMutationId++).toString(),
|
||||
},
|
||||
|
||||
@@ -23,6 +23,10 @@ const mutation = graphql`
|
||||
const clientMutationId = 0;
|
||||
|
||||
function commit(environment: Environment, input: CreateCommentReactionInput) {
|
||||
const source = environment.getStore().getSource();
|
||||
const currentCount = source.get(
|
||||
source.get(source.get(input.commentID)!.actionCounts.__ref)!.reaction.__ref
|
||||
)!.total;
|
||||
return commitMutationPromiseNormalized<MutationTypes>(environment, {
|
||||
mutation,
|
||||
variables: {
|
||||
@@ -35,6 +39,10 @@ function commit(environment: Environment, input: CreateCommentReactionInput) {
|
||||
deleteCommentReaction: {
|
||||
comment: {
|
||||
id: input.commentID,
|
||||
myActionPresence: {
|
||||
reaction: false,
|
||||
},
|
||||
actionCounts: currentCount - 1,
|
||||
},
|
||||
clientMutationId: clientMutationId.toString(),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user