Skip to content

Commit

Permalink
refactor: Replace 'PM' with 'DM' - rebased.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajnus committed Nov 14, 2024
1 parent 89bbf2e commit 366da7d
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/config/test_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
]


Expand Down
12 changes: 6 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/test_ui_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@pytest.mark.parametrize(
"msg, narrow, muted_streams, is_muted_topic_return_value, muted",
[
( # PM TEST
( # DM TEST
{
"type": "private",
# ...
Expand Down
8 changes: 4 additions & 4 deletions tests/ui_tools/test_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions tests/ui_tools/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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",
[
Expand Down
6 changes: 3 additions & 3 deletions zulipterminal/config/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion zulipterminal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions zulipterminal/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
):
Expand All @@ -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)
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 @@ -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]
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions zulipterminal/ui_tools/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion zulipterminal/ui_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 366da7d

Please sign in to comment.