Skip to content

Indent to distinguish resolved topics. #1124

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions tests/ui_tools/test_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,11 @@ def test_keypress_emoji_button(

class TestTopicButton:
@pytest.mark.parametrize(
"count, stream_id, title, stream_name",
"count, stream_id, title, stream_name, is_resolved",
[
(2, 86, "topic1", "Django"),
(1, 14, "topic2", "GSoC"),
(1000, 205, "topic3", "PTEST"),
(2, 86, "topic1", "Django", False),
(1, 14, "topic2", "GSoC", True),
Copy link
Member

Choose a reason for hiding this comment

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

Since we have a constant defined for the Unicode, let's use it here as well.

(1000, 205, "topic3", "PTEST", False),
],
)
def test_init_calls_top_button(
Expand All @@ -350,6 +350,7 @@ def test_init_calls_top_button(
title: str,
stream_id: int,
stream_name: str,
is_resolved: bool,
) -> None:
controller = mocker.Mock()
controller.model.stream_dict = {
Expand All @@ -367,8 +368,8 @@ def test_init_calls_top_button(
)

top_button.assert_called_once_with(
caption=title,
prefix_character="",
caption=title if not is_resolved else title[2:],
prefix_character=" " if not is_resolved else title[:1],
show_function=mocker.ANY, # partial
count_style="unread_count",
**params,
Expand Down
1 change: 1 addition & 0 deletions zulipterminal/api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing_extensions import Literal, TypedDict


RESOLVED_PREFIX = "✔"
EditPropagateMode = Literal["change_one", "change_all", "change_later"]
EmojiType = Literal["realm_emoji", "unicode_emoji", "zulip_extra_emoji"]
# Limited flags which could be present in update_message_flag events.
Expand Down
2 changes: 1 addition & 1 deletion zulipterminal/config/ui_sizes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
TAB_WIDTH = 3
LEFT_WIDTH = 27
LEFT_WIDTH = 29
RIGHT_WIDTH = 23
14 changes: 11 additions & 3 deletions zulipterminal/ui_tools/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import urwid
from typing_extensions import TypedDict

from zulipterminal.api_types import EditPropagateMode
from zulipterminal.api_types import RESOLVED_PREFIX, EditPropagateMode
from zulipterminal.config.keys import is_command_key, primary_key_for_command
from zulipterminal.config.regexes import REGEX_INTERNAL_LINK_STREAM_ID
from zulipterminal.config.symbols import (
Expand Down Expand Up @@ -297,11 +297,19 @@ def __init__(
stream_name=self.stream_name,
topic_name=self.topic_name,
)

# The space acts as a TopButton prefix and gives an effective 3 spaces for unresolved topics.
topic_prefix = " "
topic_name = self.topic_name
if self.topic_name.startswith(RESOLVED_PREFIX + " "):
topic_prefix = self.topic_name[:1]
topic_name = self.topic_name[2:]

super().__init__(
controller=controller,
caption=self.topic_name,
caption=topic_name,
show_function=narrow_function,
prefix_character="",
prefix_character=topic_prefix,
count=count,
count_style="unread_count",
)
Expand Down