Skip to content

Commit

Permalink
fix: do not overwrite reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jabolol committed Dec 14, 2023
1 parent 3c32e88 commit f7fa428
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use raven.
- [x] **dark** and **light** mode support
- [x] **responsive** design for mobile and desktop
- [x] **fast** and **lightweight** (100 lighthouse score)
- [x] react to **all** BeReals at once with your realMojis
- [x] react to **all** BeReals at once (does not overwrite your reactions)

# screenshots

Expand Down
1 change: 1 addition & 0 deletions islands/Me.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export default function Me() {
body: JSON.stringify({
emoji: realmoji.emoji,
access_token: getAuth()?.access_token,
user_id: user.id,
}),
});
}
Expand Down
7 changes: 5 additions & 2 deletions routes/api/reactAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ export const handler = async (
return new Response(null, { status: 405 });
}

const { access_token, emoji } = await req.json() as {
const { access_token, emoji, user_id } = await req.json() as {
access_token?: string;
emoji?: string;
user_id?: string;
};

if (!access_token || !emoji) {
Expand Down Expand Up @@ -45,7 +46,9 @@ export const handler = async (

feed.friendsPosts.reduce(async (prms, batch) => {
await prms;
await batch.posts.reduce(async (prms, post) => {
await batch.posts.filter((post) =>
post.realMojis.some((reaction) => reaction.user.id !== user_id)
).reduce(async (prms, post) => {
await prms;
await fetch(
`https://mobile.bereal.com/api/content/realmojis?postId=${post.id}&postUserId=${batch.user.id}`,
Expand Down

0 comments on commit f7fa428

Please sign in to comment.