2022-09-20 18:12:30 +00:00
|
|
|
/*
|
|
|
|
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 "dialogs/dialogs_entry.h"
|
2022-09-23 19:21:31 +00:00
|
|
|
#include "dialogs/ui/dialogs_message_view.h"
|
2022-10-07 13:56:07 +00:00
|
|
|
#include "base/flags.h"
|
2022-09-20 18:12:30 +00:00
|
|
|
|
|
|
|
class ChannelData;
|
|
|
|
|
2022-10-05 07:42:44 +00:00
|
|
|
namespace style {
|
|
|
|
struct ForumTopicIcon;
|
|
|
|
} // namespace style
|
|
|
|
|
2022-09-20 18:12:30 +00:00
|
|
|
namespace Dialogs {
|
|
|
|
class MainList;
|
|
|
|
} // namespace Dialogs
|
|
|
|
|
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
2022-10-07 11:46:27 +00:00
|
|
|
class RepliesList;
|
2022-09-20 18:12:30 +00:00
|
|
|
class Session;
|
2022-09-27 16:52:35 +00:00
|
|
|
class Forum;
|
2022-09-20 18:12:30 +00:00
|
|
|
|
2022-10-05 07:42:44 +00:00
|
|
|
[[nodiscard]] const base::flat_map<int32, QString> &ForumTopicIcons();
|
|
|
|
[[nodiscard]] const std::vector<int32> &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);
|
|
|
|
|
2022-09-20 18:12:30 +00:00
|
|
|
class ForumTopic final : public Dialogs::Entry {
|
|
|
|
public:
|
2022-09-26 13:37:32 +00:00
|
|
|
static constexpr auto kGeneralId = 1;
|
|
|
|
|
2022-09-27 16:52:35 +00:00
|
|
|
ForumTopic(not_null<History*> history, MsgId rootId);
|
2022-10-04 15:34:45 +00:00
|
|
|
~ForumTopic();
|
2022-09-20 18:12:30 +00:00
|
|
|
|
|
|
|
ForumTopic(const ForumTopic &) = delete;
|
|
|
|
ForumTopic &operator=(const ForumTopic &) = delete;
|
|
|
|
|
2022-10-07 11:46:27 +00:00
|
|
|
[[nodiscard]] std::shared_ptr<RepliesList> replies() const;
|
2022-09-27 12:05:47 +00:00
|
|
|
[[nodiscard]] not_null<ChannelData*> channel() const;
|
2022-09-27 16:52:35 +00:00
|
|
|
[[nodiscard]] not_null<History*> history() const;
|
|
|
|
[[nodiscard]] not_null<Forum*> forum() const;
|
2022-10-12 12:57:17 +00:00
|
|
|
[[nodiscard]] rpl::producer<> destroyed() const;
|
2022-09-20 18:12:30 +00:00
|
|
|
[[nodiscard]] MsgId rootId() const;
|
2022-09-26 13:37:32 +00:00
|
|
|
[[nodiscard]] bool isGeneral() const {
|
|
|
|
return (_rootId == kGeneralId);
|
|
|
|
}
|
2022-09-20 18:12:30 +00:00
|
|
|
|
2022-10-04 15:34:45 +00:00
|
|
|
void setRealRootId(MsgId realId);
|
|
|
|
|
2022-09-20 18:12:30 +00:00
|
|
|
void applyTopic(const MTPForumTopic &topic);
|
|
|
|
|
|
|
|
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<QString> &chatListNameWords() const override;
|
|
|
|
const base::flat_set<QChar> &chatListFirstLetters() const override;
|
|
|
|
|
|
|
|
[[nodiscard]] HistoryItem *lastMessage() const;
|
|
|
|
[[nodiscard]] HistoryItem *lastServerMessage() const;
|
|
|
|
[[nodiscard]] bool lastMessageKnown() const;
|
|
|
|
[[nodiscard]] bool lastServerMessageKnown() const;
|
|
|
|
|
2022-09-27 12:05:47 +00:00
|
|
|
[[nodiscard]] QString title() const;
|
2022-09-23 19:21:31 +00:00
|
|
|
void applyTitle(const QString &title);
|
2022-09-27 12:05:47 +00:00
|
|
|
[[nodiscard]] DocumentId iconId() const;
|
|
|
|
void applyIconId(DocumentId iconId);
|
2022-10-05 07:42:44 +00:00
|
|
|
[[nodiscard]] int32 colorId() const;
|
|
|
|
void applyColorId(int32 colorId);
|
2022-09-23 19:21:31 +00:00
|
|
|
void applyItemAdded(not_null<HistoryItem*> item);
|
|
|
|
void applyItemRemoved(MsgId id);
|
|
|
|
|
2022-09-20 18:12:30 +00:00
|
|
|
void loadUserpic() override;
|
|
|
|
void paintUserpic(
|
|
|
|
Painter &p,
|
|
|
|
std::shared_ptr<Data::CloudImageView> &view,
|
2022-09-29 10:33:17 +00:00
|
|
|
const Dialogs::Ui::PaintContext &context) const override;
|
2022-09-20 18:12:30 +00:00
|
|
|
|
|
|
|
[[nodiscard]] int unreadCount() const;
|
|
|
|
[[nodiscard]] bool unreadCountKnown() const;
|
|
|
|
|
|
|
|
[[nodiscard]] int unreadCountForBadge() const; // unreadCount || unreadMark ? 1 : 0.
|
|
|
|
|
|
|
|
void setUnreadMark(bool unread);
|
|
|
|
[[nodiscard]] bool unreadMark() const;
|
|
|
|
|
2022-09-23 19:21:31 +00:00
|
|
|
Ui::Text::String cloudDraftTextCache;
|
|
|
|
Dialogs::Ui::MessageView lastItemDialogsView;
|
|
|
|
|
2022-09-20 18:12:30 +00:00
|
|
|
private:
|
2022-10-07 13:56:07 +00:00
|
|
|
enum class Flag : uchar {
|
|
|
|
UnreadMark = 0x01,
|
|
|
|
};
|
|
|
|
friend inline constexpr bool is_flag_type(Flag) { return true; }
|
|
|
|
|
2022-09-20 18:12:30 +00:00
|
|
|
void indexTitleParts();
|
2022-10-05 07:42:44 +00:00
|
|
|
void validateDefaultIcon() const;
|
2022-09-20 18:12:30 +00:00
|
|
|
void applyTopicTopMessage(MsgId topMessageId);
|
|
|
|
|
|
|
|
void setLastMessage(HistoryItem *item);
|
|
|
|
void setLastServerMessage(HistoryItem *item);
|
|
|
|
void setChatListMessage(HistoryItem *item);
|
|
|
|
|
|
|
|
int chatListNameVersion() const override;
|
|
|
|
|
2022-10-07 11:46:27 +00:00
|
|
|
[[nodiscard]] Dialogs::UnreadState unreadStateFor(
|
|
|
|
int count,
|
|
|
|
bool known) const;
|
|
|
|
|
2022-10-12 12:57:17 +00:00
|
|
|
const not_null<Data::Forum*> _forum;
|
2022-09-20 18:12:30 +00:00
|
|
|
const not_null<Dialogs::MainList*> _list;
|
2022-10-07 11:46:27 +00:00
|
|
|
std::shared_ptr<RepliesList> _replies;
|
2022-10-04 15:34:45 +00:00
|
|
|
MsgId _rootId = 0;
|
2022-09-20 18:12:30 +00:00
|
|
|
|
|
|
|
QString _title;
|
2022-09-27 12:05:47 +00:00
|
|
|
DocumentId _iconId = 0;
|
2022-09-20 18:12:30 +00:00
|
|
|
base::flat_set<QString> _titleWords;
|
|
|
|
base::flat_set<QChar> _titleFirstLetters;
|
|
|
|
int _titleVersion = 0;
|
2022-10-05 07:42:44 +00:00
|
|
|
int32 _colorId = 0;
|
2022-09-20 18:12:30 +00:00
|
|
|
|
2022-09-27 16:52:35 +00:00
|
|
|
std::unique_ptr<Ui::Text::CustomEmoji> _icon;
|
2022-10-05 07:42:44 +00:00
|
|
|
mutable QImage _defaultIcon; // on-demand
|
2022-09-27 16:52:35 +00:00
|
|
|
|
2022-09-20 18:12:30 +00:00
|
|
|
std::optional<HistoryItem*> _lastMessage;
|
|
|
|
std::optional<HistoryItem*> _lastServerMessage;
|
|
|
|
std::optional<HistoryItem*> _chatListMessage;
|
2022-10-06 15:11:26 +00:00
|
|
|
base::flat_set<FullMsgId> _requestedGroups;
|
2022-10-07 13:56:07 +00:00
|
|
|
base::flags<Flag> _flags;
|
2022-09-20 18:12:30 +00:00
|
|
|
|
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Data
|