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

[WIP] Disable cycling while editing a PM #1280

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
20 changes: 12 additions & 8 deletions zulipterminal/ui_tools/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,16 @@ def _setup_common_private_compose(self) -> None:
]
self.focus_position = self.FOCUS_CONTAINER_MESSAGE

def private_box_view(
self,
*,
recipient_user_ids: Optional[List[int]] = None,
) -> None:
def update_recipients_from_user_ids(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Re this commit (and others)

  • if it only moves code around, use a refactor: area in the title, with the files you modify (could the README be clearer?)
  • I'd suggest reading about types of refactor in general, but this is an 'Extract (method/function)', so using that phrasing helps communicate what you're doing and why

self, recipient_user_ids: Optional[List[int]] = None
) -> str:
if recipient_user_ids:
self._set_regular_and_typing_recipient_user_ids(recipient_user_ids)
self.recipient_emails = [
self.model.user_id_email_dict[user_id]
for user_id in self.recipient_user_ids
]
recipient_info = ", ".join(
return ", ".join(
[
f"{self.model.user_dict[email]['full_name']} <{email}>"
for email in self.recipient_emails
Expand All @@ -227,10 +225,16 @@ def private_box_view(
else:
self._set_regular_and_typing_recipient_user_ids(None)
self.recipient_emails = []
recipient_info = ""
return ""

def private_box_view(
self,
*,
recipient_user_ids: Optional[List[int]] = None,
) -> None:
self.recipient_info = self.update_recipients_from_user_ids(recipient_user_ids)
Copy link
Collaborator

Choose a reason for hiding this comment

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

self.recipient_info doesn't appear to be used by any of your later commits, outside of the setup functions (this and the edit equivalent), so it seems like you can continue to use recipient_info instead?

self.send_next_typing_update = datetime.now()
self.to_write_box = ReadlineEdit("To: ", edit_text=recipient_info)
self.to_write_box = ReadlineEdit("To: ", edit_text=self.recipient_info)
self.to_write_box.enable_autocomplete(
func=self._to_box_autocomplete,
key=primary_key_for_command("AUTOCOMPLETE"),
Expand Down