/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "data/data_thread.h" #include "data/notify/data_peer_notify_settings.h" #include "base/flags.h" class ChannelData; namespace style { struct ForumTopicIcon; } // namespace style namespace Dialogs { class MainList; } // namespace Dialogs namespace Main { class Session; } // namespace Main namespace HistoryView { class SendActionPainter; } // namespace HistoryView namespace Data { class RepliesList; class Session; class Forum; [[nodiscard]] const base::flat_map &ForumTopicIcons(); [[nodiscard]] const std::vector &ForumTopicColorIds(); [[nodiscard]] const QString &ForumTopicIcon(int32 colorId); [[nodiscard]] QString ForumTopicIconPath(const QString &name); [[nodiscard]] QImage ForumTopicIconBackground(int32 colorId, int size); [[nodiscard]] QImage ForumTopicIconFrame( int32 colorId, const QString &title, const style::ForumTopicIcon &st); class ForumTopic final : public Thread { public: ForumTopic(not_null forum, MsgId rootId); ~ForumTopic(); not_null owningHistory() override { return history(); } [[nodiscard]] std::shared_ptr replies() const; [[nodiscard]] not_null channel() const; [[nodiscard]] not_null history() const; [[nodiscard]] not_null forum() const; [[nodiscard]] rpl::producer<> destroyed() const; [[nodiscard]] MsgId rootId() const; [[nodiscard]] bool canEdit() const; [[nodiscard]] bool canToggleClosed() const; [[nodiscard]] bool canTogglePinned() const; [[nodiscard]] bool closed() const; void setClosed(bool closed); void setClosedAndSave(bool closed); [[nodiscard]] bool creating() const; void discard(); void setRealRootId(MsgId realId); void applyTopic(const MTPDforumTopic &data); TimeId adjustedChatListTimeId() const override; int fixedOnTopIndex() const override; bool shouldBeInChatList() const override; int chatListUnreadCount() const override; bool chatListUnreadMark() const override; bool chatListMutedBadge() const override; Dialogs::UnreadState chatListUnreadState() const override; HistoryItem *chatListMessage() const override; bool chatListMessageKnown() const override; void requestChatListMessage() override; const QString &chatListName() const override; const QString &chatListNameSortKey() const override; const base::flat_set &chatListNameWords() const override; const base::flat_set &chatListFirstLetters() const override; [[nodiscard]] HistoryItem *lastMessage() const; [[nodiscard]] HistoryItem *lastServerMessage() const; [[nodiscard]] bool lastMessageKnown() const; [[nodiscard]] bool lastServerMessageKnown() const; [[nodiscard]] MsgId lastKnownServerMessageId() const; [[nodiscard]] QString title() const; void applyTitle(const QString &title); [[nodiscard]] DocumentId iconId() const; void applyIconId(DocumentId iconId); [[nodiscard]] int32 colorId() const; void applyColorId(int32 colorId); void applyItemAdded(not_null item); void applyItemRemoved(MsgId id); void maybeSetLastMessage(not_null item); [[nodiscard]] PeerNotifySettings ¬ify() { return _notify; } [[nodiscard]] const PeerNotifySettings ¬ify() const { return _notify; } void loadUserpic() override; void paintUserpic( Painter &p, std::shared_ptr &view, const Dialogs::Ui::PaintContext &context) const override; [[nodiscard]] bool isServerSideUnread( not_null item) const override; [[nodiscard]] int unreadCount() const; [[nodiscard]] bool unreadCountKnown() const; [[nodiscard]] int unreadCountForBadge() const; // unreadCount || unreadMark ? 1 : 0. void setMuted(bool muted) override; void setUnreadMark(bool unread) override; [[nodiscard]] auto sendActionPainter() ->not_null override; private: enum class Flag : uchar { Closed = (1 << 0), My = (1 << 1), }; friend inline constexpr bool is_flag_type(Flag) { return true; } using Flags = base::flags; void indexTitleParts(); void validateDefaultIcon() const; void applyTopicTopMessage(MsgId topMessageId); void growLastKnownServerMessageId(MsgId id); void setLastMessage(HistoryItem *item); void setLastServerMessage(HistoryItem *item); void setChatListMessage(HistoryItem *item); int chatListNameVersion() const override; [[nodiscard]] Dialogs::UnreadState unreadStateFor( int count, bool known) const; const not_null _forum; const not_null _list; std::shared_ptr _replies; std::shared_ptr _sendActionPainter; MsgId _rootId = 0; MsgId _lastKnownServerMessageId = 0; PeerNotifySettings _notify; QString _title; DocumentId _iconId = 0; base::flat_set _titleWords; base::flat_set _titleFirstLetters; int _titleVersion = 0; int32 _colorId = 0; Flags _flags; std::unique_ptr _icon; mutable QImage _defaultIcon; // on-demand std::optional _lastMessage; std::optional _lastServerMessage; std::optional _chatListMessage; base::flat_set _requestedGroups; rpl::lifetime _lifetime; }; } // namespace Data