|
51 | 51 | MentionedButton,
|
52 | 52 | MessageLinkButton,
|
53 | 53 | PMButton,
|
| 54 | + SpoilerButton, |
54 | 55 | StarredButton,
|
55 | 56 | StreamButton,
|
56 | 57 | TopicButton,
|
@@ -1630,6 +1631,8 @@ def __init__(
|
1630 | 1631 | msg_info.append(("Topic Links", []))
|
1631 | 1632 | if time_mentions:
|
1632 | 1633 | msg_info.append(("Time mentions", time_mentions))
|
| 1634 | + if spoilers: |
| 1635 | + msg_info.append(("Spoilers", [])) |
1633 | 1636 | if msg["reactions"]:
|
1634 | 1637 | reactions = sorted(
|
1635 | 1638 | (reaction["emoji_name"], reaction["user"]["full_name"])
|
@@ -1683,6 +1686,26 @@ def __init__(
|
1683 | 1686 | widgets = widgets[:slice_index] + topic_link_widgets + widgets[slice_index:]
|
1684 | 1687 | popup_width = max(popup_width, topic_link_width)
|
1685 | 1688 |
|
| 1689 | + if spoilers: |
| 1690 | + spoiler_buttons = [] |
| 1691 | + spoiler_width = 0 |
| 1692 | + for index, (header_len, header, content) in enumerate(spoilers): |
| 1693 | + spoiler_width = max(header_len, spoiler_width) |
| 1694 | + display_attr = None if index % 2 else "popup_contrast" |
| 1695 | + spoiler_buttons.append( |
| 1696 | + SpoilerButton(controller, header_len, header, content, display_attr) |
| 1697 | + ) |
| 1698 | + |
| 1699 | + # slice_index = Number of labels before message links + 1 newline |
| 1700 | + # + 1 'Spoilers' category label. |
| 1701 | + # + 2 for Viewing Actions category label and its newline |
| 1702 | + slice_index = len(msg_info[0][1]) + len(msg_info[1][1]) + 2 + 2 |
| 1703 | + slice_index += sum([len(w) + 2 for w in self.button_widgets]) |
| 1704 | + self.button_widgets.append(spoiler_buttons) |
| 1705 | + |
| 1706 | + widgets = widgets[:slice_index] + spoiler_buttons + widgets[slice_index:] |
| 1707 | + popup_width = max(popup_width, spoiler_width) |
| 1708 | + |
1686 | 1709 | super().__init__(controller, widgets, "MSG_INFO", popup_width, title)
|
1687 | 1710 |
|
1688 | 1711 | @staticmethod
|
|
0 commit comments