Skip to content

Commit

Permalink
views: Append topic links in message info view.
Browse files Browse the repository at this point in the history
This is a summing up commit that appends topic links in message info
view (if present).

Fixes #709.
  • Loading branch information
Ezio-Sarthak committed Feb 22, 2021
1 parent df9aa84 commit 1a91ba5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,8 @@ def __init__(self, controller: Any, msg: Message, title: str,
('Edit History', f"Press {keys} to view")
)
# Render the category using the existing table methods if links exist.
if topic_links:
msg_info.append(('Topic Links', []))
if message_links:
msg_info.append(('Message Links', []))
if time_mentions:
Expand All @@ -1267,7 +1269,18 @@ def __init__(self, controller: Any, msg: Message, title: str,
# + 1 '<Any> Links' category label.
slice_index = len(msg_info[0][1]) + 2

if topic_links:
topic_link_widgets, topic_link_width = (
self.create_link_buttons(controller, topic_links)
)

widgets = (widgets[:slice_index] + topic_link_widgets
+ widgets[slice_index:])
popup_width = max(popup_width, topic_link_width)

if message_links:
if topic_links:
slice_index += (len(topic_links) + 2)
message_link_widgets, message_link_width = (
self.create_link_buttons(controller, message_links)
)
Expand All @@ -1288,7 +1301,10 @@ def create_link_buttons(

for index, link in enumerate(links):
text, link_index, _ = links[link]
caption = f"{link_index}: {text}\n{link}"
if text:
caption = f"{link_index}: {text}\n{link}"
else:
caption = f"{link_index}: {link}"
link_width = max(
link_width,
len(max(caption.split('\n'), key=len))
Expand Down

0 comments on commit 1a91ba5

Please sign in to comment.