Skip to content

Commit 02bd05c

Browse files
sumanthvraomkp6781
authored andcommitted
buttons: Connect PopUp confirmation display for topics via keypress.
On pressing TOGGLE_MUTE_TOPIC, we now ask for confirmation before performing the action of muting/unmuting topics. Tests added.
1 parent ecc30c9 commit 02bd05c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tests/ui_tools/test_buttons.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,15 @@ def test_init_calls_mark_muted(self, mocker, stream_name, title,
318318
else:
319319
mark_muted.assert_not_called()
320320

321+
@pytest.mark.parametrize('key', keys_for_command('TOGGLE_MUTE_TOPIC'))
322+
def test_keypress_TOGGLE_MUTE_TOPIC(self, mocker, topic_button, key,
323+
widget_size):
324+
size = widget_size(topic_button)
325+
pop_up = mocker.patch(
326+
'zulipterminal.core.Controller.topic_muting_confirmation_popup')
327+
topic_button.keypress(size, key)
328+
pop_up.assert_called_once_with(topic_button)
329+
321330

322331
class TestMessageLinkButton:
323332
@pytest.fixture(autouse=True)

zulipterminal/ui_tools/buttons.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,11 @@ def mark_unmuted(self) -> None:
342342
# All messages in this topic are read.
343343
self.set_button_counts(0)
344344

345+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
346+
if is_command_key('TOGGLE_MUTE_TOPIC', key):
347+
self.controller.topic_muting_confirmation_popup(self)
348+
return super().keypress(size, key)
349+
345350

346351
class DecodedStream(TypedDict):
347352
stream_id: Optional[int]

0 commit comments

Comments
 (0)