Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. {
  2.  
  3. reactions: {
  4. dislike: {
  5. count: 0,
  6. users: {},
  7. },
  8. like: {
  9. count: 0,
  10. users: {},
  11. },
  12. maybe: {
  13. count: 0,
  14. users: {},
  15. },
  16. },
  17.  
  18. }
  19.  
  20. function updateUploadReaction(id, type, uploads) {
  21. const updatedUploads = new Map([...uploads.entries()]);
  22. const upload = updatedUploads.get(id);
  23. const userId = uuid();
  24.  
  25. uploads.forEach(() => {
  26. if (//check if userId exists) {
  27. upload.reactions[type].count += 1;
  28. upload.reactions[type].users.(// user Id value) = true;
  29. } else {
  30. upload.reactions[type].count -= 1;
  31. upload.reactions[type].users.(// user Id value) = false;
  32. }
  33. });
  34.  
  35. updatedUploads.set(id, upload);
  36.  
  37. return updatedUploads;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement