Skip to content

Commit f3d878f

Browse files
kaustubh-nairneiljp
authored andcommitted
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. Comment & slight adjustment by neiljp.
1 parent 80bb9c0 commit f3d878f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tests/ui/test_ui.py

+9
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ def test_right_column_view(self, view: View, mocker: MockerFixture) -> None:
7676
assert view.users_view == right_view()
7777
assert return_value == (line_box(), right_tab())
7878

79+
def test_set_footer_text_same_test(
80+
self, view: View, mocker: MockerFixture, text: List[str] = ["heya"]
81+
) -> None:
82+
view._w.footer.text = text
83+
84+
view.set_footer_text(text)
85+
86+
view._w.footer.set_text.assert_not_called()
87+
7988
def test_set_footer_text_default(self, view: View, mocker: MockerFixture) -> None:
8089
mocker.patch(VIEW + ".get_random_help", return_value=["some help text"])
8190

zulipterminal/ui.py

+5
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ def set_footer_text(
103103
style: str = "footer",
104104
duration: Optional[float] = None,
105105
) -> None:
106+
# Avoid updating repeatedly (then pausing and showing default text)
107+
# This is simple, though doesn't avoid starting one thread for each call
108+
if text_list == self._w.footer.text:
109+
return
110+
106111
if text_list is None:
107112
text = self.get_random_help()
108113
else:

0 commit comments

Comments
 (0)