Skip to content

Commit

Permalink
boxes/messages: Disable recpient editing when editing a private message.
Browse files Browse the repository at this point in the history
In order to fully disable editing (not only cycling to it, but e.g.
prevent editing through mouse clicks) we need to make the editing
of a message a different UI box than the usual reply.

This new box uses a urwid.Text to display the recipient information
rather than providing an editable field.

Fixes zulip#774.

Co-authored-by: zormit <[email protected]>
  • Loading branch information
Subhasish-Behera and zormit committed May 24, 2024
1 parent 751db14 commit abab4f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions zulipterminal/ui_tools/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@ def update_recipients_from_user_ids(
self.recipient_emails = []
return ""

def private_box_edit_view(
self,
*,
recipient_user_ids: Optional[List[int]] = None,
) -> None:
self.recipient_info = self.update_recipients_from_user_ids(recipient_user_ids)
self.to_write_box = urwid.Text("To: " + self.recipient_info)
self._setup_common_private_compose()

def private_box_view(
self,
*,
Expand Down
4 changes: 3 additions & 1 deletion zulipterminal/ui_tools/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,9 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
)

if self.message["type"] == "private":
self.keypress(size, primary_key_for_command("REPLY_MESSAGE"))
self.model.controller.view.write_box.private_box_edit_view(
recipient_user_ids=self.recipient_ids,
)
elif self.message["type"] == "stream":
self.model.controller.view.write_box.stream_box_edit_view(
stream_id=self.stream_id,
Expand Down

0 comments on commit abab4f4

Please sign in to comment.