Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- reactions: {
- dislike: {
- count: 0,
- users: {},
- },
- like: {
- count: 0,
- users: {},
- },
- maybe: {
- count: 0,
- users: {},
- },
- },
- }
- function updateUploadReaction(id, type, uploads) {
- const updatedUploads = new Map([...uploads.entries()]);
- const upload = updatedUploads.get(id);
- const userId = uuid();
- uploads.forEach(() => {
- if (//check if userId exists) {
- upload.reactions[type].count += 1;
- upload.reactions[type].users.(// user Id value) = true;
- } else {
- upload.reactions[type].count -= 1;
- upload.reactions[type].users.(// user Id value) = false;
- }
- });
- updatedUploads.set(id, upload);
- return updatedUploads;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement