|
51 | 51 | MentionedButton,
|
52 | 52 | MessageLinkButton,
|
53 | 53 | PMButton,
|
| 54 | + SpoilerButton, |
54 | 55 | StarredButton,
|
55 | 56 | StreamButton,
|
56 | 57 | TopicButton,
|
@@ -1646,6 +1647,8 @@ def __init__(
|
1646 | 1647 | msg_info.append(("Topic Links", []))
|
1647 | 1648 | if time_mentions:
|
1648 | 1649 | msg_info.append(("Time mentions", time_mentions))
|
| 1650 | + if spoilers: |
| 1651 | + msg_info.append(("Spoilers", [])) |
1649 | 1652 | if msg["reactions"]:
|
1650 | 1653 | reactions = sorted(
|
1651 | 1654 | (reaction["emoji_name"], reaction["user"]["full_name"])
|
@@ -1699,6 +1702,26 @@ def __init__(
|
1699 | 1702 | widgets = widgets[:slice_index] + topic_link_widgets + widgets[slice_index:]
|
1700 | 1703 | popup_width = max(popup_width, topic_link_width)
|
1701 | 1704 |
|
| 1705 | + if spoilers: |
| 1706 | + spoiler_buttons = [] |
| 1707 | + spoiler_width = 0 |
| 1708 | + for index, (header_len, header, content) in enumerate(spoilers): |
| 1709 | + spoiler_width = max(header_len, spoiler_width) |
| 1710 | + display_attr = None if index % 2 else "popup_contrast" |
| 1711 | + spoiler_buttons.append( |
| 1712 | + SpoilerButton(controller, header_len, header, content, display_attr) |
| 1713 | + ) |
| 1714 | + |
| 1715 | + # slice_index = Number of labels before message links + 1 newline |
| 1716 | + # + 1 'Spoilers' category label. |
| 1717 | + # + 2 for Viewing Actions category label and its newline |
| 1718 | + slice_index = len(msg_info[0][1]) + len(msg_info[1][1]) + 2 + 2 |
| 1719 | + slice_index += sum([len(w) + 2 for w in self.button_widgets]) |
| 1720 | + self.button_widgets.append(spoiler_buttons) |
| 1721 | + |
| 1722 | + widgets = widgets[:slice_index] + spoiler_buttons + widgets[slice_index:] |
| 1723 | + popup_width = max(popup_width, spoiler_width) |
| 1724 | + |
1702 | 1725 | super().__init__(controller, widgets, "MSG_INFO", popup_width, title)
|
1703 | 1726 |
|
1704 | 1727 | @staticmethod
|
|
0 commit comments