Function
applyPluginVote
(plugin: Plugin, vote: UserVote)
Source from the content-addressed store, hash-verified
| 13 | import { useVote } from './useVote'; |
| 14 | |
| 15 | const applyPluginVote = (plugin: Plugin, vote: UserVote): Plugin => { |
| 16 | const wasUpvoted = plugin.userVote === UserVote.Up; |
| 17 | const isUpvoted = vote === UserVote.Up; |
| 18 | |
| 19 | return { |
| 20 | ...plugin, |
| 21 | userVote: vote, |
| 22 | upvotes: plugin.upvotes + Number(isUpvoted) - Number(wasUpvoted), |
| 23 | }; |
| 24 | }; |
| 25 | |
| 26 | const updateCachedPlugin = ( |
| 27 | client: QueryClient, |
Tested by
no test coverage detected