From 13b545fffc53dcfa8e1bd2ecc4b99bcbdf493094 Mon Sep 17 00:00:00 2001 From: Ajnus Date: Wed, 23 Oct 2024 07:36:05 -0300 Subject: [PATCH 01/11] refactor: Replace 'private' with 'direct' - rebased. --- tests/conftest.py | 2 +- tests/ui_tools/test_messages.py | 7 ++++--- zulipterminal/model.py | 2 +- zulipterminal/ui_tools/messages.py | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index ad92c4cc71..36aec299fa 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -450,7 +450,7 @@ def msg_template_factory( """ Generate message template for all types of messages(stream/PM/group) """ - # TODO: Separate Message into distinct types for stream and private messages. + # TODO: Separate Message into distinct types for stream and direct messages. message = Message( id=msg_id, sender_full_name="Foo Foo", diff --git a/tests/ui_tools/test_messages.py b/tests/ui_tools/test_messages.py index 08ba7d0661..69690104b4 100644 --- a/tests/ui_tools/test_messages.py +++ b/tests/ui_tools/test_messages.py @@ -71,7 +71,7 @@ def test_init_fails_with_bad_message_type(self): with pytest.raises(RuntimeError): MessageBox(message, self.model, None) - def test_private_message_to_self(self, mocker): + def test_direct_message_to_self(self, mocker): # rebased message = dict( type="private", display_recipient=[ @@ -85,13 +85,14 @@ def test_private_message_to_self(self, mocker): ) self.model.user_email = "foo@zulip.com" mocker.patch( - MODULE + ".MessageBox._is_private_message_to_self", return_value=True + MODULE + ".MessageBox._is_direct_message_to_self", # rebased + return_value=True, ) mocker.patch.object(MessageBox, "main_view") msg_box = MessageBox(message, self.model, None) assert msg_box.recipient_emails == ["foo@zulip.com"] - msg_box._is_private_message_to_self.assert_called_once_with() + msg_box._is_direct_message_to_self.assert_called_once_with() # rebased @pytest.mark.parametrize( "content, expected_markup", diff --git a/zulipterminal/model.py b/zulipterminal/model.py index b3840a5060..1380d31028 100644 --- a/zulipterminal/model.py +++ b/zulipterminal/model.py @@ -1556,7 +1556,7 @@ def get_stream_by_id(streams: List[StreamData], stream_id: int) -> StreamData: def _handle_typing_event(self, event: Event) -> None: """ - Handle typing notifications (in private messages) + Handle typing notifications (in direct messages) """ assert event["type"] == "typing" diff --git a/zulipterminal/ui_tools/messages.py b/zulipterminal/ui_tools/messages.py index 2b67ae6e71..0da61ed9a9 100644 --- a/zulipterminal/ui_tools/messages.py +++ b/zulipterminal/ui_tools/messages.py @@ -89,7 +89,7 @@ def __init__(self, message: Message, model: "Model", last_message: Any) -> None: raise RuntimeError("Invalid message type") if self.message["type"] == "private": - if self._is_private_message_to_self(): + if self._is_direct_message_to_self(): # rebased recipient = self.message["display_recipient"][0] self.recipients_names = recipient["full_name"] self.recipient_emails = [self.model.user_email] @@ -147,7 +147,7 @@ def need_recipient_header(self) -> bool: else: raise RuntimeError("Invalid message type") - def _is_private_message_to_self(self) -> bool: + def _is_direct_message_to_self(self) -> bool: recipient_list = self.message["display_recipient"] return ( len(recipient_list) == 1 @@ -1043,7 +1043,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: self.model.controller.view.middle_column.set_focus("footer") elif is_command_key("EDIT_MESSAGE", key): # User can't edit messages of others that already have a subject - # For private messages, subject = "" (empty string) + # For direct messages, subject = "" (empty string) # This also handles the realm_message_content_edit_limit_seconds == 0 case if ( self.message["sender_id"] != self.model.user_id @@ -1115,7 +1115,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: ) return key else: - # The remaining case is of a private message not belonging to user. + # The remaining case is of a direct message not belonging to user. # Which should be already handled by the topmost if block raise RuntimeError( "Reached unexpected block. This should be handled at the top." From ccce7f9aaefaff6861b440e88177ddc4d2194e9e Mon Sep 17 00:00:00 2001 From: Ajnus Date: Wed, 23 Oct 2024 08:21:11 -0300 Subject: [PATCH 02/11] refactor: Replace 'pm' with 'dm'. --- docs/developer-feature-tutorial.md | 2 +- ...plete1-raw.png => send-dm-autocomplete1-raw.png} | Bin ...plete2-raw.png => send-dm-autocomplete2-raw.png} | Bin .../raw/{send-pm-raw.png => send-dm-raw.png} | Bin ...-autocomplete1.png => send-dm-autocomplete1.png} | Bin ...-autocomplete2.png => send-dm-autocomplete2.png} | Bin .../{send-pm.png => send-dm.png} | Bin docs/getting-started.md | 6 +++--- zulipterminal/helper.py | 4 ++-- zulipterminal/model.py | 2 +- zulipterminal/ui_tools/views.py | 10 +++++----- 11 files changed, 12 insertions(+), 12 deletions(-) rename docs/getting-started-imgs/raw/{send-pm-autocomplete1-raw.png => send-dm-autocomplete1-raw.png} (100%) rename docs/getting-started-imgs/raw/{send-pm-autocomplete2-raw.png => send-dm-autocomplete2-raw.png} (100%) rename docs/getting-started-imgs/raw/{send-pm-raw.png => send-dm-raw.png} (100%) rename docs/getting-started-imgs/{send-pm-autocomplete1.png => send-dm-autocomplete1.png} (100%) rename docs/getting-started-imgs/{send-pm-autocomplete2.png => send-dm-autocomplete2.png} (100%) rename docs/getting-started-imgs/{send-pm.png => send-dm.png} (100%) diff --git a/docs/developer-feature-tutorial.md b/docs/developer-feature-tutorial.md index 4c840e5269..8cc5838861 100644 --- a/docs/developer-feature-tutorial.md +++ b/docs/developer-feature-tutorial.md @@ -113,7 +113,7 @@ To check for the above conditions, we create a function in `ui.py`: ```python def handle_typing_event(self, event: Dict['str', Any]) -> None: - # If the user is in pm narrow with the person typing + # If the user is in dm narrow with the person typing if len(self.model.narrow) == 1 and\ self.model.narrow[0][0] == 'pm_with' and\ event['sender']['email'] in self.model.narrow[0][1].split(','): diff --git a/docs/getting-started-imgs/raw/send-pm-autocomplete1-raw.png b/docs/getting-started-imgs/raw/send-dm-autocomplete1-raw.png similarity index 100% rename from docs/getting-started-imgs/raw/send-pm-autocomplete1-raw.png rename to docs/getting-started-imgs/raw/send-dm-autocomplete1-raw.png diff --git a/docs/getting-started-imgs/raw/send-pm-autocomplete2-raw.png b/docs/getting-started-imgs/raw/send-dm-autocomplete2-raw.png similarity index 100% rename from docs/getting-started-imgs/raw/send-pm-autocomplete2-raw.png rename to docs/getting-started-imgs/raw/send-dm-autocomplete2-raw.png diff --git a/docs/getting-started-imgs/raw/send-pm-raw.png b/docs/getting-started-imgs/raw/send-dm-raw.png similarity index 100% rename from docs/getting-started-imgs/raw/send-pm-raw.png rename to docs/getting-started-imgs/raw/send-dm-raw.png diff --git a/docs/getting-started-imgs/send-pm-autocomplete1.png b/docs/getting-started-imgs/send-dm-autocomplete1.png similarity index 100% rename from docs/getting-started-imgs/send-pm-autocomplete1.png rename to docs/getting-started-imgs/send-dm-autocomplete1.png diff --git a/docs/getting-started-imgs/send-pm-autocomplete2.png b/docs/getting-started-imgs/send-dm-autocomplete2.png similarity index 100% rename from docs/getting-started-imgs/send-pm-autocomplete2.png rename to docs/getting-started-imgs/send-dm-autocomplete2.png diff --git a/docs/getting-started-imgs/send-pm.png b/docs/getting-started-imgs/send-dm.png similarity index 100% rename from docs/getting-started-imgs/send-pm.png rename to docs/getting-started-imgs/send-dm.png diff --git a/docs/getting-started.md b/docs/getting-started.md index 831290c350..337a600d8c 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -138,7 +138,7 @@ If you want to show you agree with the current message, type + to add Let's try sending a direct message to the author of a message. Select the message you sent to the [#test here](https://chat.zulip.org/#narrow/stream/7-test-here) stream earlier and press shiftr to send a direct message to yourself. Type your message in the message editor that appears at the bottom of the middle column and then type ctrld to send. Press the shiftp hotkey as we did earlier in the tutorial to narrow to your direct messages and make sure everything worked properly. - + ### Send a Direct Message to Someone New @@ -159,8 +159,8 @@ Try following the steps above to send a message to the Welcome Bot! > It's best to use ctrlf to autocomplete the name and Zulip address of the person (or bot) you want to message; if you just type in their full name, Zulip Terminal does not know for sure who you are trying to send to - and there may be multiple people with that name! - - + + ### Create a New Topic diff --git a/zulipterminal/helper.py b/zulipterminal/helper.py index a71d055b74..02be0849e8 100644 --- a/zulipterminal/helper.py +++ b/zulipterminal/helper.py @@ -206,11 +206,11 @@ def update_unreads(unreads: Dict[KeyT, int], key: KeyT) -> None: unread_counts["unread_topics"], (stream_id, message["subject"]) ) update_unreads(unread_counts["streams"], stream_id) - # self-pm has only one display_recipient + # self-dm has only one display_recipient # 1-1 pms have 2 display_recipient elif len(message["display_recipient"]) <= 2: update_unreads(unread_counts["unread_pms"], message["sender_id"]) - else: # If it's a group pm + else: # If it's a group dm update_unreads( unread_counts["unread_huddles"], frozenset( diff --git a/zulipterminal/model.py b/zulipterminal/model.py index 1380d31028..79d0d852f8 100644 --- a/zulipterminal/model.py +++ b/zulipterminal/model.py @@ -1569,7 +1569,7 @@ def _handle_typing_event(self, event: Event) -> None: sender_email = event["sender"]["email"] sender_id = event["sender"]["user_id"] - # If the user is in pm narrow with the person typing + # If the user is in dm narrow with the person typing # and the person typing isn't the user themselves if ( len(narrow) == 1 diff --git a/zulipterminal/ui_tools/views.py b/zulipterminal/ui_tools/views.py index 00158f88e2..a7bf1e23b7 100644 --- a/zulipterminal/ui_tools/views.py +++ b/zulipterminal/ui_tools/views.py @@ -630,14 +630,14 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: ) return key elif is_command_key("NEXT_UNREAD_PM", key): - # narrow to next unread pm - pm = self.model.get_next_unread_pm() - if pm is None: + # narrow to next unread dm + dm = self.model.get_next_unread_pm() + if dm is None: return key - email = self.model.user_id_email_dict[pm] + email = self.model.user_id_email_dict[dm] self.controller.narrow_to_user( recipient_emails=[email], - contextual_message_id=pm, + contextual_message_id=dm, ) elif is_command_key("PRIVATE_MESSAGE", key): # Create new PM message From 06921822afd6b295bce94163f7b4001c14899856 Mon Sep 17 00:00:00 2001 From: Ajnus Date: Wed, 23 Oct 2024 09:00:34 -0300 Subject: [PATCH 03/11] refactor: Replace '_private' with '_direct' - rebased. --- tests/ui_tools/test_boxes.py | 2 +- tests/ui_tools/test_messages.py | 7 +++---- zulipterminal/ui_tools/messages.py | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/ui_tools/test_boxes.py b/tests/ui_tools/test_boxes.py index c4e89a2b58..aff7209193 100644 --- a/tests/ui_tools/test_boxes.py +++ b/tests/ui_tools/test_boxes.py @@ -224,7 +224,7 @@ def test_not_calling_typing_method_to_oneself( ) @pytest.mark.parametrize("key", keys_for_command("SEND_MESSAGE")) - def test_not_calling_send_private_message_without_recipients( + def test_not_calling_send_direct_message_without_recipients( self, key: str, mocker: MockerFixture, diff --git a/tests/ui_tools/test_messages.py b/tests/ui_tools/test_messages.py index 69690104b4..b901c33618 100644 --- a/tests/ui_tools/test_messages.py +++ b/tests/ui_tools/test_messages.py @@ -71,7 +71,7 @@ def test_init_fails_with_bad_message_type(self): with pytest.raises(RuntimeError): MessageBox(message, self.model, None) - def test_direct_message_to_self(self, mocker): # rebased + def test_direct_message_to_self(self, mocker): message = dict( type="private", display_recipient=[ @@ -85,14 +85,13 @@ def test_direct_message_to_self(self, mocker): # rebased ) self.model.user_email = "foo@zulip.com" mocker.patch( - MODULE + ".MessageBox._is_direct_message_to_self", # rebased - return_value=True, + MODULE + ".MessageBox._is_direct_message_to_self", return_value=True ) mocker.patch.object(MessageBox, "main_view") msg_box = MessageBox(message, self.model, None) assert msg_box.recipient_emails == ["foo@zulip.com"] - msg_box._is_direct_message_to_self.assert_called_once_with() # rebased + msg_box._is_direct_message_to_self.assert_called_once_with() @pytest.mark.parametrize( "content, expected_markup", diff --git a/zulipterminal/ui_tools/messages.py b/zulipterminal/ui_tools/messages.py index 0da61ed9a9..e3afc3445e 100644 --- a/zulipterminal/ui_tools/messages.py +++ b/zulipterminal/ui_tools/messages.py @@ -89,7 +89,7 @@ def __init__(self, message: Message, model: "Model", last_message: Any) -> None: raise RuntimeError("Invalid message type") if self.message["type"] == "private": - if self._is_direct_message_to_self(): # rebased + if self._is_direct_message_to_self(): recipient = self.message["display_recipient"][0] self.recipients_names = recipient["full_name"] self.recipient_emails = [self.model.user_email] From f1daa6248cb5b73296397690085b221d2b278013 Mon Sep 17 00:00:00 2001 From: Ajnus Date: Wed, 23 Oct 2024 09:29:58 -0300 Subject: [PATCH 04/11] refactor: Replace 'private_' with 'direct_'. - rebased. --- tests/conftest.py | 20 ++++++++++---------- tests/core/test_core.py | 4 ++-- tests/helper/test_helper.py | 4 ++-- tests/model/test_model.py | 10 +++++----- zulipterminal/helper.py | 16 ++++++++-------- zulipterminal/model.py | 4 ++-- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 36aec299fa..a4efc31500 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -514,7 +514,7 @@ def group_pm_template() -> Message: @pytest.fixture(params=["pm_template", "group_pm_template"]) -def private_message_fixture(request: Any) -> Message: +def direct_message_fixture(request: Any) -> Message: return request.getfixturevalue(request.param) @@ -1068,8 +1068,8 @@ def empty_index( all_msg_ids=set(), starred_msg_ids=set(), mentioned_msg_ids=set(), - private_msg_ids=set(), - private_msg_ids_by_user_ids=defaultdict(set, {}), + direct_msg_ids=set(), + direct_msg_ids_by_user_ids=defaultdict(set, {}), stream_msg_ids_by_stream_id=defaultdict(set, {}), topic_msg_ids=defaultdict(dict, {}), edited_messages=set(), @@ -1104,7 +1104,7 @@ def index_stream(empty_index: Index) -> Index: """ index = empty_index index["stream_msg_ids_by_stream_id"] = defaultdict(set, {205: {537286}}) - index["private_msg_ids"] = {537287, 537288} + index["direct_msg_ids"] = {537287, 537288} return index @@ -1145,8 +1145,8 @@ def index_user(empty_index: Index) -> Index: """ user_ids = frozenset({5179, 5140}) index = empty_index - index["private_msg_ids_by_user_ids"] = defaultdict(set, {user_ids: {537287}}) - index["private_msg_ids"] = {537287, 537288} + index["direct_msg_ids_by_user_ids"] = defaultdict(set, {user_ids: {537287}}) + index["direct_msg_ids"] = {537287, 537288} return index @@ -1158,8 +1158,8 @@ def index_user_multiple(empty_index: Index) -> Index: """ user_ids = frozenset({5179, 5140, 5180}) index = empty_index - index["private_msg_ids_by_user_ids"] = defaultdict(set, {user_ids: {537288}}) - index["private_msg_ids"] = {537287, 537288} + index["direct_msg_ids_by_user_ids"] = defaultdict(set, {user_ids: {537288}}) + index["direct_msg_ids"] = {537287, 537288} return index @@ -1178,7 +1178,7 @@ def index_all_starred(empty_index: Index, request: Any) -> Index: msgs_with_stars = request.param index = empty_index index["starred_msg_ids"] = msgs_with_stars - index["private_msg_ids"] = {537287, 537288} + index["direct_msg_ids"] = {537287, 537288} for msg_id, msg in index["messages"].items(): if msg_id in msgs_with_stars and "starred" not in msg["flags"]: msg["flags"].append("starred") @@ -1192,7 +1192,7 @@ def index_all_mentions( mentioned_messages, wildcard_mentioned_messages = mentioned_messages_combination index = empty_index index["mentioned_msg_ids"] = mentioned_messages | wildcard_mentioned_messages - index["private_msg_ids"] = {537287, 537288} + index["direct_msg_ids"] = {537287, 537288} for msg_id, msg in index["messages"].items(): if msg_id in mentioned_messages and "mentioned" not in msg["flags"]: msg["flags"].append("mentioned") diff --git a/tests/core/test_core.py b/tests/core/test_core.py index ff6701a41d..2f772ee1b4 100644 --- a/tests/core/test_core.py +++ b/tests/core/test_core.py @@ -247,7 +247,7 @@ def test_narrow_to_user( recipients = frozenset([controller.model.user_id, user_id]) assert controller.model.recipients == recipients widget = controller.view.message_view.log.extend.call_args_list[0][0][0][0] - id_list = index_user["private_msg_ids_by_user_ids"][recipients] + id_list = index_user["direct_msg_ids_by_user_ids"][recipients] assert {widget.original_widget.message["id"]} == id_list @pytest.mark.parametrize( @@ -302,7 +302,7 @@ def test_narrow_to_all_pm( controller.view.message_view.log.clear.assert_called_once_with() widgets = controller.view.message_view.log.extend.call_args_list[0][0][0] - id_list = index_user["private_msg_ids"] + id_list = index_user["direct_msg_ids"] msg_ids = {widget.original_widget.message["id"] for widget in widgets} assert msg_ids == id_list diff --git a/tests/helper/test_helper.py b/tests/helper/test_helper.py index 2e32e5c10f..c68f62e773 100644 --- a/tests/helper/test_helper.py +++ b/tests/helper/test_helper.py @@ -178,7 +178,7 @@ def test_index_starred( model.narrow = [["is", "starred"]] model.is_search_narrow.return_value = False expected_index: Dict[str, Any] = dict( - empty_index, private_msg_ids={537287, 537288}, starred_msg_ids=msgs_with_stars + empty_index, direct_msg_ids={537287, 537288}, starred_msg_ids=msgs_with_stars ) for msg_id, msg in expected_index["messages"].items(): if msg_id in msgs_with_stars and "starred" not in msg["flags"]: @@ -211,7 +211,7 @@ def test_index_mentioned_messages( model.is_search_narrow.return_value = False expected_index: Dict[str, Any] = dict( empty_index, - private_msg_ids={537287, 537288}, + direct_msg_ids={537287, 537288}, mentioned_msg_ids=(mentioned_messages | wildcard_mentioned_messages), ) diff --git a/tests/model/test_model.py b/tests/model/test_model.py index 2cd811af4b..01bf856943 100644 --- a/tests/model/test_model.py +++ b/tests/model/test_model.py @@ -478,16 +478,16 @@ def test_set_narrow_not_already_set( {"topic_msg_ids": {1: {"BOO": {0, 1}}}}, set(), ), - ([["is", "private"]], {"private_msg_ids": {0, 1}}, {0, 1}), + ([["is", "private"]], {"direct_msg_ids": {0, 1}}, {0, 1}), ( [["pm-with", "FOO@zulip.com"]], - {"private_msg_ids_by_user_ids": {frozenset({1, 2}): {0, 1}}}, + {"direct_msg_ids_by_user_ids": {frozenset({1, 2}): {0, 1}}}, {0, 1}, ), ( [["pm-with", "FOO@zulip.com"]], { # Covers recipient empty-set case - "private_msg_ids_by_user_ids": { + "direct_msg_ids_by_user_ids": { frozenset({1, 3}): {0, 1} # NOTE {1,3} not {1,2} } }, @@ -2283,12 +2283,12 @@ def test_notify_users_enabled( [(True, "New direct message from Foo Foo"), (False, "private content here.")], ) def test_notify_users_hides_PM_content_based_on_user_setting( - self, mocker, model, private_message_fixture, hide_content, expected_content + self, mocker, model, direct_message_fixture, hide_content, expected_content ): notify = mocker.patch(MODULE + ".notify") model._user_settings["pm_content_in_desktop_notifications"] = not hide_content - message = private_message_fixture + message = direct_message_fixture message["user_id"] = 5179 message["flags"] = [] diff --git a/zulipterminal/helper.py b/zulipterminal/helper.py index 02be0849e8..55ab3779bc 100644 --- a/zulipterminal/helper.py +++ b/zulipterminal/helper.py @@ -104,8 +104,8 @@ class Index(TypedDict): all_msg_ids: Set[int] starred_msg_ids: Set[int] mentioned_msg_ids: Set[int] - private_msg_ids: Set[int] - private_msg_ids_by_user_ids: Dict[FrozenSet[int], Set[int]] + direct_msg_ids: Set[int] + direct_msg_ids_by_user_ids: Dict[FrozenSet[int], Set[int]] stream_msg_ids_by_stream_id: Dict[int, Set[int]] topic_msg_ids: Dict[int, Dict[str, Set[int]]] # Extra cached information @@ -121,8 +121,8 @@ class Index(TypedDict): all_msg_ids=set(), starred_msg_ids=set(), mentioned_msg_ids=set(), - private_msg_ids=set(), - private_msg_ids_by_user_ids=defaultdict(set), + direct_msg_ids=set(), + direct_msg_ids_by_user_ids=defaultdict(set), stream_msg_ids_by_stream_id=defaultdict(set), topic_msg_ids=defaultdict(dict), edited_messages=set(), @@ -322,7 +322,7 @@ def index_messages(messages: List[Message], model: Any, index: Index) -> Index: ... } }, - 'private_msg_ids_by_user_ids': { + 'direct_msg_ids_by_user_ids': { (3, 7): { # user_ids frozenset 51234, 56454, @@ -345,7 +345,7 @@ def index_messages(messages: List[Message], model: Any, index: Index) -> Index: 23423, ... }, - 'private_msg_ids': { + 'direct_msg_ids': { 22334, 23423, ... @@ -452,7 +452,7 @@ def index_messages(messages: List[Message], model: Any, index: Index) -> Index: index["mentioned_msg_ids"].add(msg["id"]) if msg["type"] == "private": - index["private_msg_ids"].add(msg["id"]) + index["direct_msg_ids"].add(msg["id"]) recipients = frozenset( {recipient["id"] for recipient in msg["display_recipient"]} ) @@ -463,7 +463,7 @@ def index_messages(messages: List[Message], model: Any, index: Index) -> Index: for email in narrow[0][1].split(", ") ] + [model.user_id] if recipients == frozenset(narrow_emails): - index["private_msg_ids_by_user_ids"][recipients].add(msg["id"]) + index["direct_msg_ids_by_user_ids"][recipients].add(msg["id"]) if msg["type"] == "stream" and msg["stream_id"] == model.stream_id: index["stream_msg_ids_by_stream_id"][msg["stream_id"]].add(msg["id"]) diff --git a/zulipterminal/model.py b/zulipterminal/model.py index 79d0d852f8..6e4508a9fe 100644 --- a/zulipterminal/model.py +++ b/zulipterminal/model.py @@ -370,10 +370,10 @@ def get_message_ids_in_current_narrow(self) -> Set[int]: topic = narrow[1][1] ids = index["topic_msg_ids"][stream_id].get(topic, set()) elif narrow[0][1] == "private": - ids = index["private_msg_ids"] + ids = index["direct_msg_ids"] elif narrow[0][0] == "pm-with": recipients = self.recipients - ids = index["private_msg_ids_by_user_ids"].get(recipients, set()) + ids = index["direct_msg_ids_by_user_ids"].get(recipients, set()) elif narrow[0][1] == "starred": ids = index["starred_msg_ids"] elif narrow[0][1] == "mentioned": From 373f3204745adccb9d63bdeaec6895f1e867e95f Mon Sep 17 00:00:00 2001 From: Ajnus Date: Wed, 23 Oct 2024 10:34:05 -0300 Subject: [PATCH 05/11] refactor: Replace 'PRIVATE' with 'DIRECT'. --- tests/ui/test_ui_tools.py | 4 ++-- zulipterminal/config/keys.py | 2 +- zulipterminal/helper.py | 2 +- zulipterminal/ui.py | 2 +- zulipterminal/ui_tools/views.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/ui/test_ui_tools.py b/tests/ui/test_ui_tools.py index 0a4d9ec030..42bf7c5b97 100644 --- a/tests/ui/test_ui_tools.py +++ b/tests/ui/test_ui_tools.py @@ -971,8 +971,8 @@ def test_keypress_NEXT_UNREAD_PM_no_pm( assert return_value == key - @pytest.mark.parametrize("key", keys_for_command("PRIVATE_MESSAGE")) - def test_keypress_PRIVATE_MESSAGE(self, mid_col_view, mocker, key, widget_size): + @pytest.mark.parametrize("key", keys_for_command("DIRECT_MESSAGE")) + def test_keypress_DIRECT_MESSAGE(self, mid_col_view, mocker, key, widget_size): size = widget_size(mid_col_view) mocker.patch(MIDCOLVIEW + ".focus_position") mid_col_view.model.get_next_unread_pm.return_value = None diff --git a/zulipterminal/config/keys.py b/zulipterminal/config/keys.py index a86420a364..f86f0e2cd3 100644 --- a/zulipterminal/config/keys.py +++ b/zulipterminal/config/keys.py @@ -137,7 +137,7 @@ class KeyBinding(TypedDict): 'help_text': 'New message to a stream', 'key_category': 'open_compose', }, - 'PRIVATE_MESSAGE': { + 'DIRECT_MESSAGE': { 'keys': ['x'], 'help_text': 'New message to a person or group of people', 'key_category': 'open_compose', diff --git a/zulipterminal/helper.py b/zulipterminal/helper.py index 55ab3779bc..7488a7c640 100644 --- a/zulipterminal/helper.py +++ b/zulipterminal/helper.py @@ -381,7 +381,7 @@ def index_messages(messages: List[Message], model: Any, index: Index) -> Index: 'messages': { # all the messages mapped to their id # for easy retrieval of message from id - 45645: { # PRIVATE + 45645: { # DIRECT 'id': 4290, 'timestamp': 1521817473, 'content': 'Hi @**Cordelia Lear**', diff --git a/zulipterminal/ui.py b/zulipterminal/ui.py index d0785bd928..41ccc75485 100644 --- a/zulipterminal/ui.py +++ b/zulipterminal/ui.py @@ -262,7 +262,7 @@ def keypress(self, size: urwid_Box, key: str) -> Optional[str]: or is_command_key("NEXT_UNREAD_TOPIC", key) or is_command_key("NEXT_UNREAD_PM", key) or is_command_key("STREAM_MESSAGE", key) - or is_command_key("PRIVATE_MESSAGE", key) + or is_command_key("DIRECT_MESSAGE", key) ): self.show_left_panel(visible=False) self.show_right_panel(visible=False) diff --git a/zulipterminal/ui_tools/views.py b/zulipterminal/ui_tools/views.py index a7bf1e23b7..62f6f9371b 100644 --- a/zulipterminal/ui_tools/views.py +++ b/zulipterminal/ui_tools/views.py @@ -639,7 +639,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: recipient_emails=[email], contextual_message_id=dm, ) - elif is_command_key("PRIVATE_MESSAGE", key): + elif is_command_key("DIRECT_MESSAGE", key): # Create new PM message self.footer.private_box_view() self.set_focus("footer") From 3c5d41206b4d132c24c99e6be8b4687a19273067 Mon Sep 17 00:00:00 2001 From: Ajnus Date: Wed, 23 Oct 2024 10:37:39 -0300 Subject: [PATCH 06/11] refactor: Replace 'Private' with 'Direct'. --- zulipterminal/ui_tools/boxes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zulipterminal/ui_tools/boxes.py b/zulipterminal/ui_tools/boxes.py index 1a479cadad..f32b38066b 100644 --- a/zulipterminal/ui_tools/boxes.py +++ b/zulipterminal/ui_tools/boxes.py @@ -97,7 +97,7 @@ def __init__(self, view: Any) -> None: # don't include the user's own id in this list self.typing_recipient_user_ids: List[int] - # Private message recipient text entry, None if stream-box + # Direct message recipient text entry, None if stream-box # or not initialized self.to_write_box: Optional[ReadlineEdit] From 65ebe4ee3b7a764bc330bd863bc6f5843fa8eb52 Mon Sep 17 00:00:00 2001 From: Ajnus Date: Wed, 23 Oct 2024 12:27:20 -0300 Subject: [PATCH 07/11] refactor: Replace 'pm' with 'dm' (2). --- docs/developer-feature-tutorial.md | 2 +- zulipterminal/helper.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/developer-feature-tutorial.md b/docs/developer-feature-tutorial.md index 8cc5838861..70c4e62cdb 100644 --- a/docs/developer-feature-tutorial.md +++ b/docs/developer-feature-tutorial.md @@ -2,7 +2,7 @@ This tutorial shows how typing indicator was implemented in the client. The process for adding a new feature to zulip terminal varies greatly depending on the feature. This tutorial is intended to make you familiar with the general process. -Since the typing indicator data for the other user in pm cannot be generated locally, it should be received from the client. +Since the typing indicator data for the other user in dm cannot be generated locally, it should be received from the client. A quick google search for `zulip typing indicator` points to https://zulip.readthedocs.io/en/latest/subsystems/typing-indicators.html. This document explains how typing indicator is implemented on the web client and is useful in understanding how typing indicator works internally. diff --git a/zulipterminal/helper.py b/zulipterminal/helper.py index 7488a7c640..d46bc8cb8b 100644 --- a/zulipterminal/helper.py +++ b/zulipterminal/helper.py @@ -498,9 +498,9 @@ def classify_unread_counts(model: Any) -> UnreadCounts: mentions_count = len(unread_msg_counts["mentions"]) unread_counts["all_mentions"] += mentions_count - for pm in unread_msg_counts["pms"]: - count = len(pm["unread_message_ids"]) - unread_counts["unread_pms"][pm["sender_id"]] = count + for dm in unread_msg_counts["pms"]: + count = len(dm["unread_message_ids"]) + unread_counts["unread_pms"][dm["sender_id"]] = count unread_counts["all_msg"] += count unread_counts["all_pms"] += count From f63feaf317ac1aa26d3d1cb7426259889e59f792 Mon Sep 17 00:00:00 2001 From: Ajnus Date: Wed, 23 Oct 2024 12:41:44 -0300 Subject: [PATCH 08/11] refactor: Replace 'pms' with 'dms'. --- tests/conftest.py | 2 +- zulipterminal/helper.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a4efc31500..6defd150d8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -524,7 +524,7 @@ def direct_message_fixture(request: Any) -> Message: ) def message_fixture(request: Any) -> Message: """ - Acts as a parametrize fixture for stream msg, pms and group_pms. + Acts as a parametrize fixture for stream msg, dms and group_pms. """ # `request` currently does not have an exported Pytest type. # TODO: Use the exported type when it's made available. diff --git a/zulipterminal/helper.py b/zulipterminal/helper.py index d46bc8cb8b..bef02a8cce 100644 --- a/zulipterminal/helper.py +++ b/zulipterminal/helper.py @@ -139,7 +139,7 @@ class UnreadCounts(TypedDict): all_mentions: int unread_topics: Dict[Tuple[int, str], int] # stream_id, topic unread_pms: Dict[int, int] # sender_id - unread_huddles: Dict[FrozenSet[int], int] # Group pms + unread_huddles: Dict[FrozenSet[int], int] # Group dms streams: Dict[int, int] # stream_id @@ -207,7 +207,7 @@ def update_unreads(unreads: Dict[KeyT, int], key: KeyT) -> None: ) update_unreads(unread_counts["streams"], stream_id) # self-dm has only one display_recipient - # 1-1 pms have 2 display_recipient + # 1-1 dms have 2 display_recipient elif len(message["display_recipient"]) <= 2: update_unreads(unread_counts["unread_pms"], message["sender_id"]) else: # If it's a group dm @@ -482,7 +482,7 @@ def index_messages(messages: List[Message], model: Any, index: Index) -> Index: def classify_unread_counts(model: Any) -> UnreadCounts: - # TODO: support group pms + # TODO: support group dms unread_msg_counts = model.initial_data["unread_msgs"] unread_counts = UnreadCounts( @@ -521,7 +521,7 @@ def classify_unread_counts(model: Any) -> UnreadCounts: if stream_id not in model.muted_streams: unread_counts["all_msg"] += count - # store unread count of group pms in `unread_huddles` + # store unread count of group dms in `unread_huddles` for group_pm in unread_msg_counts["huddles"]: count = len(group_pm["unread_message_ids"]) user_ids = group_pm["user_ids_string"].split(",") From dc3033ca1e6034ffbebe44b2eb46cb655a115b31 Mon Sep 17 00:00:00 2001 From: Ajnus Date: Wed, 23 Oct 2024 13:25:39 -0300 Subject: [PATCH 09/11] refactor: Replace '_pm' with '_dm' - rebased. --- tests/conftest.py | 16 ++++++++-------- tests/core/test_core.py | 4 ++-- tests/model/test_model.py | 6 +++--- tests/ui/test_ui_tools.py | 4 ++-- zulipterminal/core.py | 2 +- zulipterminal/helper.py | 22 +++++++++++----------- zulipterminal/server_url.py | 4 ++-- zulipterminal/ui_tools/buttons.py | 2 +- zulipterminal/ui_tools/messages.py | 2 +- zulipterminal/ui_tools/views.py | 2 +- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 6defd150d8..fe17dd0ed2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -506,20 +506,20 @@ def pm_template() -> Message: @pytest.fixture -def group_pm_template() -> Message: +def group_dm_template() -> Message: recipients = display_recipient_factory( [(5179, "Boo Boo"), (5140, "Foo Foo"), (5180, "Bar Bar")] ) return msg_template_factory(537288, "private", 1520918737, recipients=recipients) -@pytest.fixture(params=["pm_template", "group_pm_template"]) +@pytest.fixture(params=["pm_template", "group_dm_template"]) def direct_message_fixture(request: Any) -> Message: return request.getfixturevalue(request.param) @pytest.fixture( - params=["stream_msg_template", "pm_template", "group_pm_template"], + params=["stream_msg_template", "pm_template", "group_dm_template"], ids=["stream_message", "pm_message", "group_pm_message"], ) def message_fixture(request: Any) -> Message: @@ -536,7 +536,7 @@ def message_fixture(request: Any) -> Message: def messages_successful_response( stream_msg_template: Message, pm_template: Message, - group_pm_template: Message, + group_dm_template: Message, ) -> Dict[str, Any]: """ A successful response from a /messages API query. @@ -547,7 +547,7 @@ def messages_successful_response( "messages": [ stream_msg_template, pm_template, - group_pm_template, + group_dm_template, ], "result": "success", "msg": "", @@ -1060,7 +1060,7 @@ def initial_index() -> Index: @pytest.fixture def empty_index( - stream_msg_template: Message, pm_template: Message, group_pm_template: Message + stream_msg_template: Message, pm_template: Message, group_dm_template: Message ) -> Index: return deepcopy( Index( @@ -1080,7 +1080,7 @@ def empty_index( { stream_msg_template["id"]: stream_msg_template, pm_template["id"]: pm_template, - group_pm_template["id"]: group_pm_template, + group_dm_template["id"]: group_dm_template, }, ), ) @@ -1468,7 +1468,7 @@ def classified_unread_counts() -> Dict[str, Any]: """ return { "all_msg": 12, - "all_pms": 8, + "all_dms": 8, "unread_topics": { (1000, "Some general unread topic"): 3, (99, "Some private unread topic"): 1, diff --git a/tests/core/test_core.py b/tests/core/test_core.py index 2f772ee1b4..905bb8af58 100644 --- a/tests/core/test_core.py +++ b/tests/core/test_core.py @@ -287,7 +287,7 @@ def test_narrow_to_all_messages( assert msg_ids == id_list assert final_focus_msg_id == expected_final_focus_msg_id - def test_narrow_to_all_pm( + def test_narrow_to_all_dm( self, mocker: MockerFixture, controller: Controller, index_user: Index ) -> None: controller.model.narrow = [] @@ -296,7 +296,7 @@ def test_narrow_to_all_pm( controller.model.user_id = 1 controller.model.user_email = "some@email" - controller.narrow_to_all_pm() # FIXME: Add id narrowing test + controller.narrow_to_all_dm() # FIXME: Add id narrowing test assert controller.model.narrow == [["is", "private"]] controller.view.message_view.log.clear.assert_called_once_with() diff --git a/tests/model/test_model.py b/tests/model/test_model.py index 01bf856943..b21ea5e312 100644 --- a/tests/model/test_model.py +++ b/tests/model/test_model.py @@ -4521,20 +4521,20 @@ def test_next_unread_topic_from_message__empty_narrow( assert unread_topic == next_unread_topic - def test_get_next_unread_pm(self, model): + def test_get_next_unread_dm(self, model): model.unread_counts = {"unread_pms": {1: 1, 2: 1}} return_value = model.get_next_unread_pm() assert return_value == 1 assert model.last_unread_pm == 1 - def test_get_next_unread_pm_again(self, model): + def test_get_next_unread_dm_again(self, model): model.unread_counts = {"unread_pms": {1: 1, 2: 1}} model.last_unread_pm = 1 return_value = model.get_next_unread_pm() assert return_value == 2 assert model.last_unread_pm == 2 - def test_get_next_unread_pm_no_unread(self, model): + def test_get_next_unread_dm_no_unread(self, model): model.unread_counts = {"unread_pms": {}} return_value = model.get_next_unread_pm() assert return_value is None diff --git a/tests/ui/test_ui_tools.py b/tests/ui/test_ui_tools.py index 42bf7c5b97..1f2f0e1ccf 100644 --- a/tests/ui/test_ui_tools.py +++ b/tests/ui/test_ui_tools.py @@ -960,7 +960,7 @@ def test_keypress_NEXT_UNREAD_PM_stream( ) @pytest.mark.parametrize("key", keys_for_command("NEXT_UNREAD_PM")) - def test_keypress_NEXT_UNREAD_PM_no_pm( + def test_keypress_NEXT_UNREAD_PM_no_dm( self, mid_col_view, mocker, key, widget_size ): size = widget_size(mid_col_view) @@ -1128,7 +1128,7 @@ def mock_external_classes(self, mocker): self.view.model = mocker.Mock() self.view.model.unread_counts = { # Minimal, though an UnreadCounts "all_msg": 2, - "all_pms": 0, + "all_dms": 0, "streams": { 86: 1, 14: 1, diff --git a/zulipterminal/core.py b/zulipterminal/core.py index 61c5f79922..a2b86b93a7 100644 --- a/zulipterminal/core.py +++ b/zulipterminal/core.py @@ -653,7 +653,7 @@ def narrow_to_all_messages( ) -> None: self._narrow_to(anchor=contextual_message_id) - def narrow_to_all_pm(self, *, contextual_message_id: Optional[int] = None) -> None: + def narrow_to_all_dm(self, *, contextual_message_id: Optional[int] = None) -> None: self._narrow_to(anchor=contextual_message_id, pms=True) def narrow_to_all_starred(self) -> None: diff --git a/zulipterminal/helper.py b/zulipterminal/helper.py index bef02a8cce..97b2f571b8 100644 --- a/zulipterminal/helper.py +++ b/zulipterminal/helper.py @@ -135,7 +135,7 @@ class Index(TypedDict): class UnreadCounts(TypedDict): all_msg: int - all_pms: int + all_dms: int all_mentions: int unread_topics: Dict[Tuple[int, str], int] # stream_id, topic unread_pms: Dict[int, int] # sender_id @@ -227,7 +227,7 @@ def _set_count_in_view( ) -> None: """ This function for the most part contains the logic for setting the - count in the UI buttons. The later buttons (all_msg, all_pms) + count in the UI buttons. The later buttons (all_msg, all_dms) additionally set the current count in the model and make use of the same in the UI. """ @@ -238,7 +238,7 @@ def _set_count_in_view( toggled_stream_id = controller.view.topic_w.stream_button.stream_id user_buttons_list = controller.view.user_w.users_btn_list all_msg = controller.view.home_button - all_pm = controller.view.pm_button + all_dm = controller.view.pm_button all_mentioned = controller.view.mentioned_button for message in changed_messages: user_id = message["sender_id"] @@ -277,8 +277,8 @@ def _set_count_in_view( if user_button.user_id == user_id: user_button.update_count(user_button.count + new_count) break - unread_counts["all_pms"] += new_count - all_pm.update_count(unread_counts["all_pms"]) + unread_counts["all_dms"] += new_count + all_dm.update_count(unread_counts["all_dms"]) if add_to_counts: unread_counts["all_msg"] += new_count @@ -487,7 +487,7 @@ def classify_unread_counts(model: Any) -> UnreadCounts: unread_counts = UnreadCounts( all_msg=0, - all_pms=0, + all_dms=0, all_mentions=0, unread_topics=dict(), unread_pms=dict(), @@ -502,7 +502,7 @@ def classify_unread_counts(model: Any) -> UnreadCounts: count = len(dm["unread_message_ids"]) unread_counts["unread_pms"][dm["sender_id"]] = count unread_counts["all_msg"] += count - unread_counts["all_pms"] += count + unread_counts["all_dms"] += count for stream in unread_msg_counts["streams"]: count = len(stream["unread_message_ids"]) @@ -522,13 +522,13 @@ def classify_unread_counts(model: Any) -> UnreadCounts: unread_counts["all_msg"] += count # store unread count of group dms in `unread_huddles` - for group_pm in unread_msg_counts["huddles"]: - count = len(group_pm["unread_message_ids"]) - user_ids = group_pm["user_ids_string"].split(",") + for group in unread_msg_counts["huddles"]: + count = len(group["unread_message_ids"]) + user_ids = group["user_ids_string"].split(",") user_ids = frozenset(map(int, user_ids)) unread_counts["unread_huddles"][user_ids] = count unread_counts["all_msg"] += count - unread_counts["all_pms"] += count + unread_counts["all_dms"] += count return unread_counts diff --git a/zulipterminal/server_url.py b/zulipterminal/server_url.py index 9d3dce7561..ca996a2202 100644 --- a/zulipterminal/server_url.py +++ b/zulipterminal/server_url.py @@ -53,7 +53,7 @@ def near_stream_message_url(server_url: str, message: Message) -> str: return full_url -def near_pm_message_url(server_url: str, message: Message) -> str: +def near_dm_message_url(server_url: str, message: Message) -> str: """ Returns the complete encoded URL of a message from #narrow/pm-with. Referred from zerver/lib/url_encoding.py. @@ -83,5 +83,5 @@ def near_message_url(server_url: str, message: Message) -> str: if message["type"] == "stream": url = near_stream_message_url(server_url, message) else: - url = near_pm_message_url(server_url, message) + url = near_dm_message_url(server_url, message) return url diff --git a/zulipterminal/ui_tools/buttons.py b/zulipterminal/ui_tools/buttons.py index 8e67d79adf..a56bb197bf 100644 --- a/zulipterminal/ui_tools/buttons.py +++ b/zulipterminal/ui_tools/buttons.py @@ -152,7 +152,7 @@ def __init__(self, *, controller: Any, count: int) -> None: label_markup=(None, button_text), prefix_markup=("title", DIRECT_MESSAGE_MARKER), suffix_markup=("unread_count", ""), - show_function=controller.narrow_to_all_pm, + show_function=controller.narrow_to_all_dm, count=count, ) diff --git a/zulipterminal/ui_tools/messages.py b/zulipterminal/ui_tools/messages.py index e3afc3445e..e091e0e091 100644 --- a/zulipterminal/ui_tools/messages.py +++ b/zulipterminal/ui_tools/messages.py @@ -964,7 +964,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: self.model.unset_search_narrow() if self.message["type"] == "private": if len(self.model.narrow) == 1 and self.model.narrow[0][0] == "pm-with": - self.model.controller.narrow_to_all_pm( + self.model.controller.narrow_to_all_dm( contextual_message_id=self.message["id"], ) else: diff --git a/zulipterminal/ui_tools/views.py b/zulipterminal/ui_tools/views.py index 62f6f9371b..6f85b2b501 100644 --- a/zulipterminal/ui_tools/views.py +++ b/zulipterminal/ui_tools/views.py @@ -792,7 +792,7 @@ def menu_view(self) -> Any: count = self.model.unread_counts.get("all_msg", 0) self.view.home_button = HomeButton(controller=self.controller, count=count) - count = self.model.unread_counts.get("all_pms", 0) + count = self.model.unread_counts.get("all_dms", 0) self.view.pm_button = PMButton(controller=self.controller, count=count) self.view.mentioned_button = MentionedButton( From 89bbf2e834c57f1b0ba112dabda504cbfe6c20ab Mon Sep 17 00:00:00 2001 From: Ajnus Date: Wed, 23 Oct 2024 13:52:43 -0300 Subject: [PATCH 10/11] refactor: Replace 'pm_' with 'dm_' - rebased. --- docs/developer-feature-tutorial.md | 2 +- tests/conftest.py | 30 +++++++++++++++--------------- tests/core/test_core.py | 2 +- tests/model/test_model.py | 10 +++++----- tests/ui/test_ui_tools.py | 4 ++-- tests/ui_tools/test_boxes.py | 2 +- tests/ui_tools/test_buttons.py | 8 ++++---- tests/ui_tools/test_messages.py | 2 +- tests/ui_tools/test_popups.py | 4 ++-- zulipterminal/core.py | 2 +- zulipterminal/helper.py | 8 ++++---- zulipterminal/model.py | 8 ++++---- zulipterminal/server_url.py | 4 ++-- zulipterminal/ui.py | 2 +- zulipterminal/ui_tools/views.py | 4 ++-- 15 files changed, 46 insertions(+), 46 deletions(-) diff --git a/docs/developer-feature-tutorial.md b/docs/developer-feature-tutorial.md index 70c4e62cdb..e0e41a2f9c 100644 --- a/docs/developer-feature-tutorial.md +++ b/docs/developer-feature-tutorial.md @@ -115,7 +115,7 @@ To check for the above conditions, we create a function in `ui.py`: def handle_typing_event(self, event: Dict['str', Any]) -> None: # If the user is in dm narrow with the person typing if len(self.model.narrow) == 1 and\ - self.model.narrow[0][0] == 'pm_with' and\ + self.model.narrow[0][0] == 'dm_with' and\ event['sender']['email'] in self.model.narrow[0][1].split(','): if event['op'] == 'start': user = self.model.user_dict[event['sender']['email']] diff --git a/tests/conftest.py b/tests/conftest.py index fe17dd0ed2..5b4b38377f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -500,7 +500,7 @@ def extra_stream_msg_template() -> Message: @pytest.fixture -def pm_template() -> Message: +def dm_template() -> Message: recipients = display_recipient_factory([(5179, "Boo Boo"), (5140, "Foo Foo")]) return msg_template_factory(537287, "private", 1520918736, recipients=recipients) @@ -513,18 +513,18 @@ def group_dm_template() -> Message: return msg_template_factory(537288, "private", 1520918737, recipients=recipients) -@pytest.fixture(params=["pm_template", "group_dm_template"]) +@pytest.fixture(params=["dm_template", "group_dm_template"]) def direct_message_fixture(request: Any) -> Message: return request.getfixturevalue(request.param) @pytest.fixture( - params=["stream_msg_template", "pm_template", "group_dm_template"], - ids=["stream_message", "pm_message", "group_pm_message"], + params=["stream_msg_template", "dm_template", "group_dm_template"], + ids=["stream_message", "dm_message", "group_dm_message"], ) def message_fixture(request: Any) -> Message: """ - Acts as a parametrize fixture for stream msg, dms and group_pms. + Acts as a parametrize fixture for stream msg, dms and group_dms. """ # `request` currently does not have an exported Pytest type. # TODO: Use the exported type when it's made available. @@ -535,7 +535,7 @@ def message_fixture(request: Any) -> Message: @pytest.fixture def messages_successful_response( stream_msg_template: Message, - pm_template: Message, + dm_template: Message, group_dm_template: Message, ) -> Dict[str, Any]: """ @@ -546,7 +546,7 @@ def messages_successful_response( "anchor": 10000000000000000, "messages": [ stream_msg_template, - pm_template, + dm_template, group_dm_template, ], "result": "success", @@ -634,10 +634,10 @@ def topics() -> List[str]: ], ids=[ "stream_mention__stream_wildcard", - "stream+pm_mention__no_wildcard", - "no_mention__stream+pm_wildcard", - "stream+group_mention__pm_wildcard", - "pm_mention__stream+group_wildcard", + "stream+dm_mention__no_wildcard", + "no_mention__stream+dm_wildcard", + "stream+group_mention__dm_wildcard", + "dm_mention__stream+group_wildcard", "group_mention__all_wildcard", "all_mention__stream_wildcard", "stream+group_mention__wildcard", @@ -1060,7 +1060,7 @@ def initial_index() -> Index: @pytest.fixture def empty_index( - stream_msg_template: Message, pm_template: Message, group_dm_template: Message + stream_msg_template: Message, dm_template: Message, group_dm_template: Message ) -> Index: return deepcopy( Index( @@ -1079,7 +1079,7 @@ def empty_index( lambda: {}, { stream_msg_template["id"]: stream_msg_template, - pm_template["id"]: pm_template, + dm_template["id"]: dm_template, group_dm_template["id"]: group_dm_template, }, ), @@ -1140,7 +1140,7 @@ def index_multiple_topic_msg( @pytest.fixture def index_user(empty_index: Index) -> Index: """ - Expected index of initial_data when model.narrow = [['pm_with', + Expected index of initial_data when model.narrow = [['dm_with', 'boo@zulip.com'], """ user_ids = frozenset({5179, 5140}) @@ -1153,7 +1153,7 @@ def index_user(empty_index: Index) -> Index: @pytest.fixture def index_user_multiple(empty_index: Index) -> Index: """ - Expected index of initial_data when model.narrow = [['pm_with', + Expected index of initial_data when model.narrow = [['dm_with', 'boo@zulip.com, bar@zulip.com'], """ user_ids = frozenset({5179, 5140, 5180}) diff --git a/tests/core/test_core.py b/tests/core/test_core.py index 905bb8af58..205be04e04 100644 --- a/tests/core/test_core.py +++ b/tests/core/test_core.py @@ -514,7 +514,7 @@ def test_stream_muting_confirmation_popup( "Default_all_msg_search", "redo_default_search", "search_within_stream", - "pm_search_again", + "dm_search_again", "search_within_topic_narrow", ], ) diff --git a/tests/model/test_model.py b/tests/model/test_model.py index b21ea5e312..aa118a5e59 100644 --- a/tests/model/test_model.py +++ b/tests/model/test_model.py @@ -407,9 +407,9 @@ def test_is_search_narrow(self, model, narrow, is_search_narrow): "bad_args", [ dict(topic="some topic"), - dict(stream="foo", pm_with="someone"), - dict(topic="blah", pm_with="someone"), - dict(pm_with="someone", topic="foo"), + dict(stream="foo", dm_with="someone"), + dict(topic="blah", dm_with="someone"), + dict(dm_with="someone", topic="foo"), ], ) def test_set_narrow_bad_input(self, model, bad_args): @@ -428,7 +428,7 @@ def test_set_narrow_bad_input(self, model, bad_args): ([["is", "starred"]], dict(starred=True)), ([["is", "mentioned"]], dict(mentioned=True)), ([["is", "private"]], dict(pms=True)), - ([["pm-with", "FOO@zulip.com"]], dict(pm_with="FOO@zulip.com")), + ([["pm-with", "FOO@zulip.com"]], dict(dm_with="FOO@zulip.com")), ], ) def test_set_narrow_already_set(self, model, narrow, good_args): @@ -449,7 +449,7 @@ def test_set_narrow_already_set(self, model, narrow, good_args): ([], [["is", "starred"]], dict(starred=True)), ([], [["is", "mentioned"]], dict(mentioned=True)), ([], [["is", "private"]], dict(pms=True)), - ([], [["pm-with", "FOOBOO@gmail.com"]], dict(pm_with="FOOBOO@gmail.com")), + ([], [["pm-with", "FOOBOO@gmail.com"]], dict(dm_with="FOOBOO@gmail.com")), ], ) def test_set_narrow_not_already_set( diff --git a/tests/ui/test_ui_tools.py b/tests/ui/test_ui_tools.py index 1f2f0e1ccf..cf170a5a04 100644 --- a/tests/ui/test_ui_tools.py +++ b/tests/ui/test_ui_tools.py @@ -1152,7 +1152,7 @@ def mock_external_classes(self, mocker): def test_menu_view(self, mocker): self.streams_view = mocker.patch(VIEWS + ".LeftColumnView.streams_view") home_button = mocker.patch(VIEWS + ".HomeButton") - pm_button = mocker.patch(VIEWS + ".PMButton") + dm_button = mocker.patch(VIEWS + ".PMButton") starred_button = mocker.patch(VIEWS + ".StarredButton") mocker.patch(VIEWS + ".urwid.ListBox") mocker.patch(VIEWS + ".urwid.SimpleFocusListWalker") @@ -1161,7 +1161,7 @@ def test_menu_view(self, mocker): home_button.assert_called_once_with( controller=left_col_view.controller, count=2 ) - pm_button.assert_called_once_with(controller=left_col_view.controller, count=0) + dm_button.assert_called_once_with(controller=left_col_view.controller, count=0) starred_button.assert_called_once_with( controller=left_col_view.controller, count=3 ) diff --git a/tests/ui_tools/test_boxes.py b/tests/ui_tools/test_boxes.py index aff7209193..91dc3c401f 100644 --- a/tests/ui_tools/test_boxes.py +++ b/tests/ui_tools/test_boxes.py @@ -186,7 +186,7 @@ def test_generic_autocomplete_stream_and_topic( ([1001], False, []), ([1001, 11], True, [11]), ], - ids=["pm_only_with_oneself", "group_pm"], + ids=["dm_only_with_oneself", "group_dm"], ) def test_not_calling_typing_method_to_oneself( self, diff --git a/tests/ui_tools/test_buttons.py b/tests/ui_tools/test_buttons.py index adc2faa127..ca23b2a5e2 100644 --- a/tests/ui_tools/test_buttons.py +++ b/tests/ui_tools/test_buttons.py @@ -181,12 +181,12 @@ def test_update_widget( class TestPMButton: def test_button_text_length(self, mocker: MockerFixture, count: int = 10) -> None: - pm_button = PMButton(controller=mocker.Mock(), count=count) - assert len(pm_button.label_text) == 20 + dm_button = PMButton(controller=mocker.Mock(), count=count) + assert len(dm_button.label_text) == 20 def test_button_text_title(self, mocker: MockerFixture, count: int = 10) -> None: - pm_button = PMButton(controller=mocker.Mock(), count=count) - title_text = pm_button.label_text[:-3].strip() + dm_button = PMButton(controller=mocker.Mock(), count=count) + title_text = dm_button.label_text[:-3].strip() assert title_text == "Direct messages" diff --git a/tests/ui_tools/test_messages.py b/tests/ui_tools/test_messages.py index b901c33618..f96229ec7c 100644 --- a/tests/ui_tools/test_messages.py +++ b/tests/ui_tools/test_messages.py @@ -883,7 +883,7 @@ def test_main_view_generates_stream_header( {"type": "stream"}, ], ids=[ - "larger_pm_group", + "larger_dm_group", "stream_before", ], ) diff --git a/tests/ui_tools/test_popups.py b/tests/ui_tools/test_popups.py index 878be178c4..840735029c 100644 --- a/tests/ui_tools/test_popups.py +++ b/tests/ui_tools/test_popups.py @@ -1023,8 +1023,8 @@ def test_keypress_any_key( ], ids=[ "stream_message_id", - "pm_message_id", - "group_pm_message_id", + "dm_message_id", + "group_dm_message_id", ], ) def test_keypress_edit_history( diff --git a/zulipterminal/core.py b/zulipterminal/core.py index a2b86b93a7..e18ebf936d 100644 --- a/zulipterminal/core.py +++ b/zulipterminal/core.py @@ -645,7 +645,7 @@ def narrow_to_user( ) -> None: self._narrow_to( anchor=contextual_message_id, - pm_with=", ".join(recipient_emails), + dm_with=", ".join(recipient_emails), ) def narrow_to_all_messages( diff --git a/zulipterminal/helper.py b/zulipterminal/helper.py index 97b2f571b8..329df8b83f 100644 --- a/zulipterminal/helper.py +++ b/zulipterminal/helper.py @@ -238,7 +238,7 @@ def _set_count_in_view( toggled_stream_id = controller.view.topic_w.stream_button.stream_id user_buttons_list = controller.view.user_w.users_btn_list all_msg = controller.view.home_button - all_dm = controller.view.pm_button + all_dm = controller.view.dm_button all_mentioned = controller.view.mentioned_button for message in changed_messages: user_id = message["sender_id"] @@ -719,12 +719,12 @@ def notify_if_message_sent_outside_narrow( topic_narrow = stream_narrow + [["topic", message["subject"]]] check_narrow_and_notify(stream_narrow, topic_narrow, controller) elif message["type"] == "private": - pm_narrow = [["is", "private"]] + dm_narrow = [["is", "private"]] recipient_emails = [ controller.model.user_id_email_dict[user_id] for user_id in message["to"] ] - pm_with_narrow = [["pm-with", ", ".join(recipient_emails)]] - check_narrow_and_notify(pm_narrow, pm_with_narrow, controller) + dm_with_narrow = [["pm-with", ", ".join(recipient_emails)]] + check_narrow_and_notify(dm_narrow, dm_with_narrow, controller) def hash_util_decode(string: str) -> str: diff --git a/zulipterminal/model.py b/zulipterminal/model.py index 6e4508a9fe..87ec5f913c 100644 --- a/zulipterminal/model.py +++ b/zulipterminal/model.py @@ -301,7 +301,7 @@ def set_narrow( stream: Optional[str] = None, topic: Optional[str] = None, pms: bool = False, - pm_with: Optional[str] = None, + dm_with: Optional[str] = None, starred: bool = False, mentioned: bool = False, ) -> bool: @@ -311,7 +311,7 @@ def set_narrow( frozenset(["stream"]): [["stream", stream]], frozenset(["stream", "topic"]): [["stream", stream], ["topic", topic]], frozenset(["pms"]): [["is", "private"]], - frozenset(["pm_with"]): [["pm-with", pm_with]], + frozenset(["dm_with"]): [["pm-with", dm_with]], frozenset(["starred"]): [["is", "starred"]], frozenset(["mentioned"]): [["is", "mentioned"]], } @@ -325,8 +325,8 @@ def set_narrow( if new_narrow != self.narrow: self.narrow = new_narrow - if pm_with is not None and new_narrow[0][0] == "pm-with": - users = pm_with.split(", ") + if dm_with is not None and new_narrow[0][0] == "pm-with": + users = dm_with.split(", ") self.recipients = frozenset( [self.user_dict[user]["user_id"] for user in users] + [self.user_id] ) diff --git a/zulipterminal/server_url.py b/zulipterminal/server_url.py index ca996a2202..4c1f0fccef 100644 --- a/zulipterminal/server_url.py +++ b/zulipterminal/server_url.py @@ -61,12 +61,12 @@ def near_dm_message_url(server_url: str, message: Message) -> str: message_id = str(message["id"]) str_user_ids = [str(recipient["id"]) for recipient in message["display_recipient"]] - pm_str = ",".join(str_user_ids) + "-pm" + dm_str = ",".join(str_user_ids) + "-pm" parts = [ server_url, "#narrow", "pm-with", - pm_str, + dm_str, "near", message_id, ] diff --git a/zulipterminal/ui.py b/zulipterminal/ui.py index 41ccc75485..9f8bac8871 100644 --- a/zulipterminal/ui.py +++ b/zulipterminal/ui.py @@ -270,7 +270,7 @@ def keypress(self, size: urwid_Box, key: str) -> Optional[str]: self.middle_column.keypress(size, key) return key elif is_command_key("ALL_PM", key): - self.pm_button.activate(key) + self.dm_button.activate(key) elif is_command_key("ALL_STARRED", key): self.starred_button.activate(key) elif is_command_key("ALL_MENTIONS", key): diff --git a/zulipterminal/ui_tools/views.py b/zulipterminal/ui_tools/views.py index 6f85b2b501..1d4124268c 100644 --- a/zulipterminal/ui_tools/views.py +++ b/zulipterminal/ui_tools/views.py @@ -793,7 +793,7 @@ def menu_view(self) -> Any: self.view.home_button = HomeButton(controller=self.controller, count=count) count = self.model.unread_counts.get("all_dms", 0) - self.view.pm_button = PMButton(controller=self.controller, count=count) + self.view.dm_button = PMButton(controller=self.controller, count=count) self.view.mentioned_button = MentionedButton( controller=self.controller, @@ -807,7 +807,7 @@ def menu_view(self) -> Any: ) menu_btn_list = [ self.view.home_button, - self.view.pm_button, + self.view.dm_button, self.view.mentioned_button, self.view.starred_button, ] From 366da7dc0fa9459418d00a1e7b0a5ef146d1075a Mon Sep 17 00:00:00 2001 From: Ajnus Date: Mon, 28 Oct 2024 12:08:42 -0300 Subject: [PATCH 11/11] refactor: Replace 'PM' with 'DM' - rebased. --- docs/FAQ.md | 2 +- tests/config/test_keys.py | 2 +- tests/conftest.py | 12 ++++++------ tests/ui/test_ui_tools.py | 10 +++++----- tests/ui/test_utils.py | 2 +- tests/ui_tools/test_buttons.py | 8 ++++---- tests/ui_tools/test_messages.py | 6 +++--- zulipterminal/config/keys.py | 6 +++--- zulipterminal/core.py | 2 +- zulipterminal/ui.py | 4 ++-- zulipterminal/ui_tools/boxes.py | 8 ++++---- zulipterminal/ui_tools/buttons.py | 4 ++-- zulipterminal/ui_tools/utils.py | 2 +- zulipterminal/ui_tools/views.py | 8 ++++---- 14 files changed, 38 insertions(+), 38 deletions(-) diff --git a/docs/FAQ.md b/docs/FAQ.md index 04a5d160d9..03d839a679 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -369,7 +369,7 @@ through autocomplete depend upon the context automatically. * `P` (with stream color) if the stream is valid and private, * `✗` if the stream is invalid. -![PM recipients header](https://user-images.githubusercontent.com/55916430/118403345-9d422800-b68b-11eb-9005-6d2af74adab9.png) +![DM recipients header](https://user-images.githubusercontent.com/55916430/118403345-9d422800-b68b-11eb-9005-6d2af74adab9.png) **NOTE:** If a direct message recipient's name contains comma(s) (`,`), they are currently treated as comma-separated recipients. diff --git a/tests/config/test_keys.py b/tests/config/test_keys.py index 752e69af29..bb38bdb623 100644 --- a/tests/config/test_keys.py +++ b/tests/config/test_keys.py @@ -144,7 +144,7 @@ def test_display_key_for_urwid_key(urwid_key: str, display_key: str) -> None: COMMAND_TO_DISPLAY_KEYS = [ ("NEXT_LINE", ["Down", "Ctrl n"]), ("TOGGLE_STAR_STATUS", ["Ctrl s", "*"]), - ("ALL_PM", ["P"]), + ("ALL_DM", ["P"]), ] diff --git a/tests/conftest.py b/tests/conftest.py index 5b4b38377f..39c12a703a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -520,11 +520,11 @@ def direct_message_fixture(request: Any) -> Message: @pytest.fixture( params=["stream_msg_template", "dm_template", "group_dm_template"], - ids=["stream_message", "dm_message", "group_dm_message"], + ids=["stream_message", "pm_message", "group_pm_message"], ) def message_fixture(request: Any) -> Message: """ - Acts as a parametrize fixture for stream msg, dms and group_dms. + Acts as a parametrize fixture for stream msg, dms and group_pms. """ # `request` currently does not have an exported Pytest type. # TODO: Use the exported type when it's made available. @@ -634,10 +634,10 @@ def topics() -> List[str]: ], ids=[ "stream_mention__stream_wildcard", - "stream+dm_mention__no_wildcard", - "no_mention__stream+dm_wildcard", - "stream+group_mention__dm_wildcard", - "dm_mention__stream+group_wildcard", + "stream+pm_mention__no_wildcard", + "no_mention__stream+pm_wildcard", + "stream+group_mention__pm_wildcard", + "pm_mention__stream+group_wildcard", "group_mention__all_wildcard", "all_mention__stream_wildcard", "stream+group_mention__wildcard", diff --git a/tests/ui/test_ui_tools.py b/tests/ui/test_ui_tools.py index cf170a5a04..28ae866a63 100644 --- a/tests/ui/test_ui_tools.py +++ b/tests/ui/test_ui_tools.py @@ -942,8 +942,8 @@ def test_keypress_NEXT_UNREAD_TOPIC_no_stream( assert mid_col_view.controller.narrow_to_topic.called is False assert return_value == key - @pytest.mark.parametrize("key", keys_for_command("NEXT_UNREAD_PM")) - def test_keypress_NEXT_UNREAD_PM_stream( + @pytest.mark.parametrize("key", keys_for_command("NEXT_UNREAD_DM")) + def test_keypress_NEXT_UNREAD_DM_stream( self, mid_col_view, mocker, key, widget_size ): size = widget_size(mid_col_view) @@ -959,8 +959,8 @@ def test_keypress_NEXT_UNREAD_PM_stream( contextual_message_id=1, ) - @pytest.mark.parametrize("key", keys_for_command("NEXT_UNREAD_PM")) - def test_keypress_NEXT_UNREAD_PM_no_dm( + @pytest.mark.parametrize("key", keys_for_command("NEXT_UNREAD_DM")) + def test_keypress_NEXT_UNREAD_DM_no_dm( self, mid_col_view, mocker, key, widget_size ): size = widget_size(mid_col_view) @@ -1152,7 +1152,7 @@ def mock_external_classes(self, mocker): def test_menu_view(self, mocker): self.streams_view = mocker.patch(VIEWS + ".LeftColumnView.streams_view") home_button = mocker.patch(VIEWS + ".HomeButton") - dm_button = mocker.patch(VIEWS + ".PMButton") + dm_button = mocker.patch(VIEWS + ".DMButton") starred_button = mocker.patch(VIEWS + ".StarredButton") mocker.patch(VIEWS + ".urwid.ListBox") mocker.patch(VIEWS + ".urwid.SimpleFocusListWalker") diff --git a/tests/ui/test_utils.py b/tests/ui/test_utils.py index 88f0e16785..b84c01c426 100644 --- a/tests/ui/test_utils.py +++ b/tests/ui/test_utils.py @@ -13,7 +13,7 @@ @pytest.mark.parametrize( "msg, narrow, muted_streams, is_muted_topic_return_value, muted", [ - ( # PM TEST + ( # DM TEST { "type": "private", # ... diff --git a/tests/ui_tools/test_buttons.py b/tests/ui_tools/test_buttons.py index ca23b2a5e2..0e78ac3cc1 100644 --- a/tests/ui_tools/test_buttons.py +++ b/tests/ui_tools/test_buttons.py @@ -10,10 +10,10 @@ from zulipterminal.config.symbols import CHECK_MARK, MUTE_MARKER from zulipterminal.ui_tools.buttons import ( DecodedStream, + DMButton, EmojiButton, MessageLinkButton, ParsedNarrowLink, - PMButton, StarredButton, StreamButton, TopButton, @@ -179,13 +179,13 @@ def test_update_widget( set_attr_map.assert_called_once_with({None: top_button.label_style}) -class TestPMButton: +class TestDMButton: def test_button_text_length(self, mocker: MockerFixture, count: int = 10) -> None: - dm_button = PMButton(controller=mocker.Mock(), count=count) + dm_button = DMButton(controller=mocker.Mock(), count=count) assert len(dm_button.label_text) == 20 def test_button_text_title(self, mocker: MockerFixture, count: int = 10) -> None: - dm_button = PMButton(controller=mocker.Mock(), count=count) + dm_button = DMButton(controller=mocker.Mock(), count=count) title_text = dm_button.label_text[:-3].strip() assert title_text == "Direct messages" diff --git a/tests/ui_tools/test_messages.py b/tests/ui_tools/test_messages.py index f96229ec7c..5b557284c6 100644 --- a/tests/ui_tools/test_messages.py +++ b/tests/ui_tools/test_messages.py @@ -827,7 +827,7 @@ def test_main_view_renders_slash_me(self, mocker, message, content, is_me_messag ids=[ "different_stream_before", "different_topic_before", - "PM_before", + "DM_before", ], ) def test_main_view_generates_stream_header( @@ -887,7 +887,7 @@ def test_main_view_generates_stream_header( "stream_before", ], ) - def test_main_view_generates_PM_header( + def test_main_view_generates_DM_header( self, mocker, message, to_vary_in_last_message ): last_message = dict(message, **to_vary_in_last_message) @@ -1041,7 +1041,7 @@ def test_msg_generates_search_and_header_bar( assert header_bar[0].text.startswith(assert_header_bar) assert search_bar.text_to_fill == assert_search_bar - # Assume recipient (PM/stream/topic) header is unchanged below + # Assume recipient (DM/stream/topic) header is unchanged below @pytest.mark.parametrize( "message", [ diff --git a/zulipterminal/config/keys.py b/zulipterminal/config/keys.py index f86f0e2cd3..5095b6c893 100644 --- a/zulipterminal/config/keys.py +++ b/zulipterminal/config/keys.py @@ -214,7 +214,7 @@ class KeyBinding(TypedDict): 'help_text': 'View all messages', 'key_category': 'narrowing', }, - 'ALL_PM': { + 'ALL_DM': { 'keys': ['P'], 'help_text': 'View all direct messages', 'key_category': 'narrowing', @@ -234,7 +234,7 @@ class KeyBinding(TypedDict): 'help_text': 'Next unread topic', 'key_category': 'narrowing', }, - 'NEXT_UNREAD_PM': { + 'NEXT_UNREAD_DM': { 'keys': ['p'], 'help_text': 'Next unread direct message', 'key_category': 'narrowing', @@ -346,7 +346,7 @@ class KeyBinding(TypedDict): 'help_text': 'Show/hide user information', 'key_category': 'user_list', }, - 'NARROW_TO_USER_PM': { + 'NARROW_TO_USER_DM': { # Added to clarify functionality of button activation, # as opposed to opening user profile or other effects. # Implementation uses ACTIVATE_BUTTON command. diff --git a/zulipterminal/core.py b/zulipterminal/core.py index e18ebf936d..540144174f 100644 --- a/zulipterminal/core.py +++ b/zulipterminal/core.py @@ -222,7 +222,7 @@ def clamp(n: int, minn: int, maxn: int) -> int: width = clamp(max_cols, min_width, max_width) scaling = 1 - ((width - min_width) / (4 * (max_width - min_width))) max_popup_cols = int(scaling * max_cols) - # Scale Height + # Scale Height. max_popup_rows = 3 * max_rows // 4 return max_popup_cols, max_popup_rows diff --git a/zulipterminal/ui.py b/zulipterminal/ui.py index 9f8bac8871..a0fa510507 100644 --- a/zulipterminal/ui.py +++ b/zulipterminal/ui.py @@ -260,7 +260,7 @@ def keypress(self, size: urwid_Box, key: str) -> Optional[str]: elif ( is_command_key("SEARCH_MESSAGES", key) or is_command_key("NEXT_UNREAD_TOPIC", key) - or is_command_key("NEXT_UNREAD_PM", key) + or is_command_key("NEXT_UNREAD_DM", key) or is_command_key("STREAM_MESSAGE", key) or is_command_key("DIRECT_MESSAGE", key) ): @@ -269,7 +269,7 @@ def keypress(self, size: urwid_Box, key: str) -> Optional[str]: self.body.focus_col = 1 self.middle_column.keypress(size, key) return key - elif is_command_key("ALL_PM", key): + elif is_command_key("ALL_DM", key): self.dm_button.activate(key) elif is_command_key("ALL_STARRED", key): self.starred_button.activate(key) diff --git a/zulipterminal/ui_tools/boxes.py b/zulipterminal/ui_tools/boxes.py index f32b38066b..8552a7cf58 100644 --- a/zulipterminal/ui_tools/boxes.py +++ b/zulipterminal/ui_tools/boxes.py @@ -87,12 +87,12 @@ def __init__(self, view: Any) -> None: # Set to int for stream box only self.stream_id: Optional[int] - # Used in PM and stream boxes - # (empty list implies PM box empty, or not initialized) + # Used in DM and stream boxes + # (empty list implies DM box empty, or not initialized) # Prioritizes autocomplete in message body self.recipient_user_ids: List[int] - # Updates server on PM typing events + # Updates server on DM typing events # Is separate from recipient_user_ids because we # don't include the user's own id in this list self.typing_recipient_user_ids: List[int] @@ -168,7 +168,7 @@ def _set_regular_and_typing_recipient_user_ids( self.typing_recipient_user_ids = list() def send_stop_typing_status(self) -> None: - # Send 'stop' updates only for PM narrows, when there are recipients + # Send 'stop' updates only for DM narrows, when there are recipients # to send to and a prior 'start' status has already been sent. if ( self.compose_box_status == "open_with_private" diff --git a/zulipterminal/ui_tools/buttons.py b/zulipterminal/ui_tools/buttons.py index a56bb197bf..2a0e4c86db 100644 --- a/zulipterminal/ui_tools/buttons.py +++ b/zulipterminal/ui_tools/buttons.py @@ -143,9 +143,9 @@ def __init__(self, *, controller: Any, count: int) -> None: ) -class PMButton(TopButton): +class DMButton(TopButton): def __init__(self, *, controller: Any, count: int) -> None: - button_text = f"Direct messages [{primary_display_key_for_command('ALL_PM')}]" + button_text = f"Direct messages [{primary_display_key_for_command('ALL_DM')}]" super().__init__( controller=controller, diff --git a/zulipterminal/ui_tools/utils.py b/zulipterminal/ui_tools/utils.py index d055af44b7..5a3878d8d0 100644 --- a/zulipterminal/ui_tools/utils.py +++ b/zulipterminal/ui_tools/utils.py @@ -58,7 +58,7 @@ def create_msg_box_list( # The SIM114 warnings are ignored here since combining the branches would be less clear def is_muted(msg: Message, model: Any) -> bool: - # PMs cannot be muted + # DMs cannot be muted if msg["type"] == "private": # noqa: SIM114 return False # In a topic narrow diff --git a/zulipterminal/ui_tools/views.py b/zulipterminal/ui_tools/views.py index 1d4124268c..bf681ee924 100644 --- a/zulipterminal/ui_tools/views.py +++ b/zulipterminal/ui_tools/views.py @@ -46,11 +46,11 @@ from zulipterminal.server_url import near_message_url from zulipterminal.ui_tools.boxes import PanelSearchBox from zulipterminal.ui_tools.buttons import ( + DMButton, EmojiButton, HomeButton, MentionedButton, MessageLinkButton, - PMButton, StarredButton, StreamButton, TopicButton, @@ -629,7 +629,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: topic_name=topic, ) return key - elif is_command_key("NEXT_UNREAD_PM", key): + elif is_command_key("NEXT_UNREAD_DM", key): # narrow to next unread dm dm = self.model.get_next_unread_pm() if dm is None: @@ -640,7 +640,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: contextual_message_id=dm, ) elif is_command_key("DIRECT_MESSAGE", key): - # Create new PM message + # Create new DM message self.footer.private_box_view() self.set_focus("footer") self.footer.focus_position = 0 @@ -793,7 +793,7 @@ def menu_view(self) -> Any: self.view.home_button = HomeButton(controller=self.controller, count=count) count = self.model.unread_counts.get("all_dms", 0) - self.view.dm_button = PMButton(controller=self.controller, count=count) + self.view.dm_button = DMButton(controller=self.controller, count=count) self.view.mentioned_button = MentionedButton( controller=self.controller,