Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable cycling to recipients when editing PM #1504

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions tests/ui_tools/test_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def test_footer_notification_on_invalid_recipients(
),
],
)
def test_update_recipients(
def test_update_recipients_from_emails_in_widget(
self,
write_box: WriteBox,
header: str,
Expand All @@ -432,7 +432,7 @@ def test_update_recipients(
assert write_box.to_write_box is not None
write_box.to_write_box.edit_text = header

write_box.update_recipients(write_box.to_write_box)
write_box.update_recipients_from_emails_in_widget(write_box.to_write_box)

assert write_box.recipient_emails == expected_recipient_emails
assert write_box.recipient_user_ids == expected_recipient_user_ids
Expand Down
8 changes: 4 additions & 4 deletions zulipterminal/ui_tools/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def track_idleness_and_update_status() -> None:

urwid.connect_signal(self.msg_write_box, "change", on_type_send_status)

def update_recipients(self, write_box: ReadlineEdit) -> None:
def update_recipients_from_emails_in_widget(self, write_box: ReadlineEdit) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that this naming using 'in_widget' occurs only in this function in the codebase. Does it actually help us to differentiate it from valid emails, or is it redundant?

self.recipient_emails = re.findall(REGEX_RECIPIENT_EMAIL, write_box.edit_text)
self._set_regular_and_typing_recipient_user_ids(
[self.model.user_dict[email]["user_id"] for email in self.recipient_emails]
Expand Down Expand Up @@ -761,7 +761,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
)
if not all_valid:
return key
self.update_recipients(self.to_write_box)
self.update_recipients_from_emails_in_widget(self.to_write_box)
if self.recipient_user_ids:
success = self.model.send_private_message(
recipients=self.recipient_user_ids,
Expand Down Expand Up @@ -815,7 +815,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
)
if not all_valid:
return key
self.update_recipients(self.to_write_box)
self.update_recipients_from_emails_in_widget(self.to_write_box)
this_draft: Composition = PrivateComposition(
type="private",
to=self.recipient_user_ids,
Expand Down Expand Up @@ -893,7 +893,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
# We extract recipients' user_ids and emails only once we know
# that all the recipients are valid, to avoid including any
# invalid ones.
self.update_recipients(self.to_write_box)
self.update_recipients_from_emails_in_widget(self.to_write_box)

if not self.msg_body_edit_enabled:
return key
Expand Down