Skip to content

Commit 5f9c68c

Browse files
committed
views: Remove reaction on unchecking box.
1 parent 136a7cd commit 5f9c68c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

zulipterminal/core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def show_stream_info(self, stream_id: int) -> None:
164164
show_stream_view = StreamInfoView(self, stream_id)
165165
self.show_pop_up(show_stream_view)
166166

167+
# TODO: remove
167168
def toggle_message_reaction(self, button: Any) -> None:
168169
self.model.react_to_message(button.message,
169170
button.emoji_name)

zulipterminal/ui_tools/views.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,8 @@ def __init__(self, controller: Any, title: str, message: Message
13451345
self.controller = controller
13461346
self.message = message
13471347
widgets = [urwid.CheckBox(reaction['emoji_name'], state=True,
1348-
checked_symbol='✓')
1348+
checked_symbol='✓',
1349+
on_state_change=self.remove_reaction)
13491350
for reaction in message['reactions']
13501351
if(controller.model.user_has_reacted_to_msg(
13511352
reaction['emoji_name'], message,
@@ -1359,6 +1360,16 @@ def keypress(self, size: urwid_Size, key: str) -> str:
13591360
self.controller.show_emoji_picker(self.message)
13601361
return super().keypress(size, key)
13611362

1363+
def remove_reaction(self, checkbox: Any, state: bool) -> None:
1364+
if not state:
1365+
self.controller.model.react_to_message(self.message,
1366+
checkbox.get_label())
1367+
check_boxes = self.contents['body'][0].body
1368+
check_boxes.remove(checkbox)
1369+
removed_check_boxes = urwid.ListBox(
1370+
urwid.SimpleFocusListWalker(check_boxes))
1371+
self.contents['body'] = (removed_check_boxes, None)
1372+
13621373

13631374
class EmojiPickerView(PopUpView):
13641375
def __init__(self, controller: Any, title: str, emoji_names: List[str],

0 commit comments

Comments
 (0)