Skip to content

Commit 5c631d9

Browse files
committed
bugfix: ui: Do not update footer if new text is same as current.
This prevents rapid footer updates if an error message is triggered multiple times. An example of this would be a user holding-down/pressing too often the edit message key on a message that cannot be edited. This fix does not account for updates that might happen for different messages, but we can safely assume that the time difference between such messages would not be too small and such a bug would most likely not occur. Test added. Fixes zulip#647.
1 parent a88c5fa commit 5c631d9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

tests/ui/test_ui.py

+7
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ def test_right_column_view(self, view, mocker):
5252
assert view.users_view == right_view()
5353
assert return_value == line_box()
5454

55+
def test_set_footer_text_same_test(self, view, mocker, text=['heya']):
56+
view._w.footer.text = text
57+
58+
view.set_footer_text(text)
59+
60+
view._w.footer.set_text.assert_not_called()
61+
5562
def test_set_footer_text_default(self, view, mocker):
5663
mocker.patch('zulipterminal.ui.View.get_random_help',
5764
return_value=['some help text'])

zulipterminal/ui.py

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def set_footer_text(self, text_list: Optional[List[Any]]=None,
7777
if text_list is None:
7878
text = self.get_random_help()
7979
else:
80+
if self._w.footer.text == text_list:
81+
return
8082
text = text_list
8183
self._w.footer.set_text(text)
8284
self.controller.update_screen()

0 commit comments

Comments
 (0)