mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
test optimistic ui on vote with sleep server-side
This commit is contained in:
parent
123da6b79d
commit
3390b5af24
4 changed files with 15 additions and 11 deletions
|
@ -120,7 +120,7 @@ srp@1.0.10
|
|||
standard-minifier-css@1.3.2
|
||||
standard-minifier-js@1.2.1
|
||||
standard-minifiers@1.0.6
|
||||
std:accounts-ui@1.2.6
|
||||
std:accounts-ui@1.2.8
|
||||
tmeasday:check-npm-versions@0.3.1
|
||||
tmeasday:publish-counts@0.8.0
|
||||
tracker@1.1.1
|
||||
|
|
|
@ -86,25 +86,28 @@ Vote.contextTypes = {
|
|||
// graphql
|
||||
const VoteWithMutation = graphql(gql`
|
||||
mutation postVote($postId: String, $voteType: String) {
|
||||
postVote(postId: $postId, voteType: $voteType)
|
||||
postVote(postId: $postId, voteType: $voteType) {
|
||||
_id
|
||||
baseScore
|
||||
}
|
||||
}
|
||||
`, {
|
||||
props: ({ownProps, mutate}) => ({
|
||||
vote: ({post, voteType, currentUser}) => {
|
||||
const { baseScore, _id } = Telescope.operateOnItem(Posts, post, currentUser, voteType, true);
|
||||
|
||||
const votedItem = Telescope.operateOnItem(Posts, post, currentUser, voteType, true);
|
||||
|
||||
console.log("// votedItem")
|
||||
console.log(votedItem)
|
||||
|
||||
// console.log("// votedItem")
|
||||
// console.log(votedItem)
|
||||
return mutate({
|
||||
variables: {postId: post._id, voteType},
|
||||
optimisticResponse: {
|
||||
__typename: 'Mutation',
|
||||
postVote: votedItem
|
||||
postVote: {
|
||||
__typename: 'Post',
|
||||
_id,
|
||||
baseScore,
|
||||
},
|
||||
},
|
||||
}).then(() => {
|
||||
return ownProps.refetchQuery();
|
||||
})
|
||||
}
|
||||
}),
|
||||
|
|
|
@ -292,5 +292,5 @@ Meteor.methods({
|
|||
});
|
||||
|
||||
Telescope.graphQL.addMutation(`
|
||||
postVote(postId: String, voteType: String) : Boolean
|
||||
postVote(postId: String, voteType: String) : Post
|
||||
`);
|
||||
|
|
|
@ -25,6 +25,7 @@ Telescope.operateOnItem = function (collection, item, user, operation, isSimulat
|
|||
|
||||
const simulatedItem = {
|
||||
__typename: 'Post',
|
||||
_id: item._id,
|
||||
upvoters: item.upvoters,
|
||||
upvotes: item.upvotes,
|
||||
baseScore: item.baseScore
|
||||
|
|
Loading…
Add table
Reference in a new issue