diff --git a/tests/helper/test_helper.py b/tests/helper/test_helper.py index 785c8dbbd03..ed73cfe2587 100644 --- a/tests/helper/test_helper.py +++ b/tests/helper/test_helper.py @@ -305,7 +305,8 @@ def test_display_error_if_present(mocker, response, footer_updated): display_error_if_present(response, controller) if footer_updated: - set_footer_text.assert_called_once_with(response['msg'], 3) + set_footer_text.assert_called_once_with(response['msg'], + 'task:failure', 3) else: set_footer_text.assert_not_called() @@ -340,7 +341,7 @@ def test_notify_if_message_sent_outside_narrow(mocker, req, narrow, if footer_updated: set_footer_text.assert_called_once_with( - 'Message is sent outside of current narrow.', 3) + 'Message is sent outside of current narrow.', 'task:success', 3) else: set_footer_text.assert_not_called() diff --git a/tests/model/test_model.py b/tests/model/test_model.py index 89176ca1ac8..93189727faa 100644 --- a/tests/model/test_model.py +++ b/tests/model/test_model.py @@ -562,7 +562,7 @@ def test_update_stream_message(self, mocker, model, set_footer_text = model.controller.view.set_footer_text if result and footer_updated: set_footer_text.assert_called_once_with( - "You changed a message's topic.", 3) + "You changed a message's topic.", 'task:success', 3) else: set_footer_text.assert_not_called() diff --git a/tests/ui/test_ui.py b/tests/ui/test_ui.py index 993edac4f8e..fcb9e534921 100644 --- a/tests/ui/test_ui.py +++ b/tests/ui/test_ui.py @@ -76,7 +76,7 @@ def test_set_footer_text_with_duration(self, view, mocker, return_value=['some help text']) mock_sleep = mocker.patch('time.sleep') - view.set_footer_text([custom_text], duration) + view.set_footer_text([custom_text], duration=duration) view._w.footer.set_text.assert_has_calls([ mocker.call([custom_text]), diff --git a/zulipterminal/helper.py b/zulipterminal/helper.py index 821cc63b3f5..58113d20e55 100644 --- a/zulipterminal/helper.py +++ b/zulipterminal/helper.py @@ -648,7 +648,7 @@ def notify(title: str, html_text: str) -> str: def display_error_if_present(response: Dict[str, Any], controller: Any ) -> None: if response['result'] == 'error' and hasattr(controller, 'view'): - controller.view.set_footer_text(response['msg'], 3) + controller.view.set_footer_text(response['msg'], 'task:failure', 3) def check_narrow_and_notify(outer_narrow: List[Any], @@ -659,7 +659,7 @@ def check_narrow_and_notify(outer_narrow: List[Any], if (current_narrow != [] and current_narrow != outer_narrow and current_narrow != inner_narrow): controller.view.set_footer_text( - 'Message is sent outside of current narrow.', 3) + 'Message is sent outside of current narrow.', 'task:success', 3) def notify_if_message_sent_outside_narrow(message: Composition, diff --git a/zulipterminal/model.py b/zulipterminal/model.py index 6b996489b7f..8113800ab0d 100644 --- a/zulipterminal/model.py +++ b/zulipterminal/model.py @@ -376,7 +376,8 @@ def session_draft_message(self) -> Optional[Composition]: def save_draft(self, draft: Composition) -> None: self._draft = deepcopy(draft) - self.controller.view.set_footer_text("Saved message as draft", 3) + self.controller.view.set_footer_text("Saved message as draft", + 'task:success', 3) @asynch def toggle_message_star_status(self, message: Message) -> None: @@ -474,7 +475,8 @@ def update_stream_message(self, topic: str, message_id: int, new_topic = request['topic'] view = self.controller.view if old_topic != new_topic: - view.set_footer_text("You changed a message's topic.", 3) + view.set_footer_text("You changed a message's topic.", + 'task:success', 3) return response['result'] == 'success' diff --git a/zulipterminal/ui.py b/zulipterminal/ui.py index 08d2711423e..26d17d9460d 100644 --- a/zulipterminal/ui.py +++ b/zulipterminal/ui.py @@ -78,12 +78,14 @@ def get_random_help(self) -> List[Any]: @asynch def set_footer_text(self, text_list: Optional[List[Any]]=None, + theme: str='area:neutral', duration: Optional[float]=None) -> None: if text_list is None: text = self.get_random_help() else: text = text_list self._w.footer.set_text(text) + self._w.footer.set_attr_map({None: theme}) self.controller.update_screen() if duration is not None: assert duration > 0 @@ -250,7 +252,7 @@ def keypress(self, size: Tuple[int, int], key: str) -> Optional[str]: self.middle_column.set_focus('footer') else: self.set_footer_text('No draft message was saved in' - ' this session.', 3) + ' this session.', 'task:failure', 3) return key elif is_command_key('ABOUT', key): self.controller.show_about() diff --git a/zulipterminal/ui_tools/boxes.py b/zulipterminal/ui_tools/boxes.py index ee38d6007af..fe04bc97cb4 100644 --- a/zulipterminal/ui_tools/boxes.py +++ b/zulipterminal/ui_tools/boxes.py @@ -535,7 +535,8 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: ) else: self.view.set_footer_text("Cannot send message without" - " specifying recipients.", 3) + " specifying recipients.", + 'task:failure', 3) success = None if success: self.msg_write_box.edit_text = '' @@ -594,7 +595,8 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: '_REVERSE' )) ) - self.view.set_footer_text(invalid_stream_error, 3) + self.view.set_footer_text(invalid_stream_error, + 'task:failure', 3) return key user_ids = self.model.get_other_subscribers_in_stream( stream_name=stream_name) @@ -625,7 +627,8 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: if invalid_emails: invalid_emails_error = ('Invalid recipient(s) - ' + ', '.join(invalid_emails)) - self.view.set_footer_text(invalid_emails_error, 3) + self.view.set_footer_text(invalid_emails_error, + 'task:failure', 3) return key users = self.model.user_dict self.recipient_user_ids = [users[email]['user_id'] @@ -1499,12 +1502,13 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: elif is_command_key('EDIT_MESSAGE', key): if self.message['sender_id'] != self.model.user_id: self.model.controller.view.set_footer_text( - " You can't edit messages sent by other users.", 3) + " You can't edit messages sent by other users.", + 'task:failure', 3) return key # Check if editing is allowed in the realm elif not self.model.initial_data['realm_allow_message_editing']: self.model.controller.view.set_footer_text( - " Editing sent message is disabled.", 3) + " Editing sent message is disabled.", 'task:failure', 3) return key # Check if message is still editable, i.e. within # the time limit. @@ -1516,13 +1520,13 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: if self.message['type'] == 'private': self.model.controller.view.set_footer_text( " Time Limit for editing the message has" - " been exceeded.", 3) + " been exceeded.", 'task:failure', 3) return key elif self.message['type'] == 'stream': self.model.controller.view.set_footer_text( " Only topic editing allowed." " Time Limit for editing the message body has" - " been exceeded.", 3) + " been exceeded.", 'task:failure', 3) msg_body_edit_enabled = False if self.message['type'] == 'private': diff --git a/zulipterminal/ui_tools/buttons.py b/zulipterminal/ui_tools/buttons.py index f21af7754d6..2358e7aeb4c 100644 --- a/zulipterminal/ui_tools/buttons.py +++ b/zulipterminal/ui_tools/buttons.py @@ -513,7 +513,7 @@ def handle_narrow_link(self) -> None: error = self._validate_narrow_link(parsed_link) if error: - self.view.set_footer_text(f" {error}", duration=3) + self.view.set_footer_text(f" {error}", 'task:failure', duration=3) else: self._switch_narrow_to(parsed_link)