Skip to content

Commit

Permalink
refactor: views: Declare some local variables as member variables.
Browse files Browse the repository at this point in the history
This is done in MsgInfoView, as it is an aspect for future commit.
  • Loading branch information
Ezio-Sarthak committed Jan 6, 2021
1 parent 044d0cd commit a3a0181
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,7 @@ def __init__(self, controller: Any, msg: Message, title: str,
time_mentions: List[Tuple[str, str]],
) -> None:
self.msg = msg
self.controller = controller
self.topic_links = topic_links
self.message_links = message_links
self.time_mentions = time_mentions
Expand Down Expand Up @@ -1161,9 +1162,10 @@ def __init__(self, controller: Any, msg: Message, title: str,
grouped_reactions[reaction] = user
msg_info.append(('Reactions', list(grouped_reactions.items())))

popup_width, column_widths = self.calculate_table_widths(msg_info,
len(title))
widgets = self.make_table_with_categories(msg_info, column_widths)
self.popup_width, column_widths = (self.calculate_table_widths(
msg_info, len(title)))
self.widgets = (self.make_table_with_categories(
msg_info, column_widths))

if message_links:
message_link_widgets = []
Expand All @@ -1184,11 +1186,12 @@ def __init__(self, controller: Any, msg: Message, title: str,
# slice_index = Number of labels before message links + 1 newline
# + 1 'Message Links' category label.
slice_index = len(msg_info[0][1]) + 2
widgets = (widgets[:slice_index] + message_link_widgets
+ widgets[slice_index:])
popup_width = max(popup_width, message_link_width)
self.widgets = (self.widgets[:slice_index] + message_link_widgets
+ self.widgets[slice_index:])
self.popup_width = max(self.popup_width, message_link_width)

super().__init__(controller, widgets, 'MSG_INFO', popup_width, title)
super().__init__(self.controller, self.widgets, 'MSG_INFO',
self.popup_width, title)

def keypress(self, size: urwid_Size, key: str) -> str:
if (is_command_key('EDIT_HISTORY', key)
Expand Down

0 comments on commit a3a0181

Please sign in to comment.