Skip to content

Commit 9c7b36c

Browse files
Niloth-ptimabbott
authored andcommitted
bugfix: model: Remove the reaction corresponding to the reaction event.
When multiple users shared an emoji reaction, the prior implementation did not account for individual user IDs, leading to buggy handling of 'remove reaction' events.
1 parent 16862cd commit 9c7b36c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

zulipterminal/model.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,9 +1849,20 @@ def _handle_reaction_event(self, event: Event) -> None:
18491849
)
18501850
else:
18511851
for reaction in message["reactions"]:
1852-
# Since Who reacted is not displayed,
1853-
# remove the first one encountered
1854-
if reaction["emoji_code"] == event["emoji_code"]:
1852+
reaction_user_id = (
1853+
reaction["user"]["id"]
1854+
if "user" in reaction
1855+
else reaction["user_id"]
1856+
)
1857+
event_user_id = (
1858+
event["user"]["user_id"]
1859+
if event.get("user") and isinstance(event["user"], dict)
1860+
else event["user_id"]
1861+
)
1862+
if (
1863+
reaction["emoji_code"] == event["emoji_code"]
1864+
and reaction_user_id == event_user_id
1865+
):
18551866
message["reactions"].remove(reaction)
18561867
break
18571868

0 commit comments

Comments
 (0)