Move is_hidden to ForumTopicInfo.

This commit is contained in:
levlam 2022-11-30 15:47:55 +03:00
parent 20ba802e48
commit f6e8e85547
7 changed files with 24 additions and 13 deletions

View File

@ -1321,13 +1321,13 @@ forumTopicIcon color:int32 custom_emoji_id:int64 = ForumTopicIcon;
//@creator_id Identifier of the creator of the topic //@creator_id Identifier of the creator of the topic
//@is_outgoing True, if the topic was created by the current user //@is_outgoing True, if the topic was created by the current user
//@is_closed True, if the topic is closed //@is_closed True, if the topic is closed
forumTopicInfo message_thread_id:int53 name:string icon:forumTopicIcon creation_date:int32 creator_id:MessageSender is_outgoing:Bool is_closed:Bool = ForumTopicInfo; //@is_hidden True, if the topic is hidden above the topic list and closed; for General topic only
forumTopicInfo message_thread_id:int53 name:string icon:forumTopicIcon creation_date:int32 creator_id:MessageSender is_outgoing:Bool is_closed:Bool is_hidden:Bool = ForumTopicInfo;
//@description Describes a forum topic //@description Describes a forum topic
//@info Basic information about the topic //@info Basic information about the topic
//@last_message Last message in the topic; may be null //@last_message Last message in the topic; may be null
//@is_pinned True, if the topic is pinned in the topic list //@is_pinned True, if the topic is pinned in the topic list
//@is_hidden True, if the topic is hidden above the topic list and closed; for General topic only
//@unread_count Number of unread messages in the topic //@unread_count Number of unread messages in the topic
//@last_read_inbox_message_id Identifier of the last read incoming message //@last_read_inbox_message_id Identifier of the last read incoming message
//@last_read_outbox_message_id Identifier of the last read outgoing message //@last_read_outbox_message_id Identifier of the last read outgoing message
@ -1335,7 +1335,7 @@ forumTopicInfo message_thread_id:int53 name:string icon:forumTopicIcon creation_
//@unread_reaction_count Number of messages with unread reactions in the topic //@unread_reaction_count Number of messages with unread reactions in the topic
//@notification_settings Notification settings for the topic //@notification_settings Notification settings for the topic
//@draft_message A draft of a message in the topic; may be null //@draft_message A draft of a message in the topic; may be null
forumTopic info:forumTopicInfo last_message:message is_pinned:Bool is_hidden:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 unread_reaction_count:int32 notification_settings:chatNotificationSettings draft_message:draftMessage = ForumTopic; forumTopic info:forumTopicInfo last_message:message is_pinned:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 unread_reaction_count:int32 notification_settings:chatNotificationSettings draft_message:draftMessage = ForumTopic;
//@class RichText @description Describes a text object inside an instant-view web page //@class RichText @description Describes a text object inside an instant-view web page

View File

@ -25,7 +25,6 @@ ForumTopic::ForumTopic(Td *td, tl_object_ptr<telegram_api::ForumTopic> &&forum_t
auto *forum_topic = static_cast<telegram_api::forumTopic *>(forum_topic_ptr.get()); auto *forum_topic = static_cast<telegram_api::forumTopic *>(forum_topic_ptr.get());
is_short_ = forum_topic->short_; is_short_ = forum_topic->short_;
is_pinned_ = forum_topic->pinned_; is_pinned_ = forum_topic->pinned_;
is_hidden_ = forum_topic->hidden_;
notification_settings_ = notification_settings_ =
get_dialog_notification_settings(std::move(forum_topic->notify_settings_), false, false, false, false); get_dialog_notification_settings(std::move(forum_topic->notify_settings_), false, false, false, false);
draft_message_ = get_draft_message(td->contacts_manager_.get(), std::move(forum_topic->draft_)); draft_message_ = get_draft_message(td->contacts_manager_.get(), std::move(forum_topic->draft_));
@ -51,9 +50,9 @@ td_api::object_ptr<td_api::forumTopic> ForumTopic::get_forum_topic_object(Td *td
// TODO last_message // TODO last_message
auto draft_message = get_draft_message_object(draft_message_); auto draft_message = get_draft_message_object(draft_message_);
return td_api::make_object<td_api::forumTopic>( return td_api::make_object<td_api::forumTopic>(
info.get_forum_topic_info_object(td), nullptr, is_pinned_, is_hidden_, unread_count_, info.get_forum_topic_info_object(td), nullptr, is_pinned_, unread_count_, last_read_inbox_message_id_.get(),
last_read_inbox_message_id_.get(), last_read_outbox_message_id_.get(), unread_mention_count_, last_read_outbox_message_id_.get(), unread_mention_count_, unread_reaction_count_,
unread_reaction_count_, get_chat_notification_settings_object(&notification_settings_), std::move(draft_message)); get_chat_notification_settings_object(&notification_settings_), std::move(draft_message));
} }
} // namespace td } // namespace td

View File

@ -22,7 +22,6 @@ class Td;
class ForumTopic { class ForumTopic {
bool is_short_ = false; bool is_short_ = false;
bool is_pinned_ = false; bool is_pinned_ = false;
bool is_hidden_ = false;
int32 unread_count_ = 0; int32 unread_count_ = 0;
MessageId last_message_id_; MessageId last_message_id_;
MessageId last_read_inbox_message_id_; MessageId last_read_inbox_message_id_;

View File

@ -28,6 +28,7 @@ ForumTopicInfo::ForumTopicInfo(const tl_object_ptr<telegram_api::ForumTopic> &fo
creator_dialog_id_ = DialogId(forum_topic->from_id_); creator_dialog_id_ = DialogId(forum_topic->from_id_);
is_outgoing_ = forum_topic->my_; is_outgoing_ = forum_topic->my_;
is_closed_ = forum_topic->closed_; is_closed_ = forum_topic->closed_;
is_hidden_ = forum_topic->hidden_;
if (creation_date_ <= 0 || !top_thread_message_id_.is_valid() || !creator_dialog_id_.is_valid()) { if (creation_date_ <= 0 || !top_thread_message_id_.is_valid() || !creator_dialog_id_.is_valid()) {
LOG(ERROR) << "Receive " << to_string(forum_topic_ptr); LOG(ERROR) << "Receive " << to_string(forum_topic_ptr);
@ -48,6 +49,10 @@ bool ForumTopicInfo::apply_edited_data(const ForumTopicEditedData &edited_data)
is_closed_ = edited_data.is_closed_; is_closed_ = edited_data.is_closed_;
is_changed = true; is_changed = true;
} }
if (edited_data.edit_is_hidden_ && edited_data.is_hidden_ != is_hidden_) {
is_hidden_ = edited_data.is_hidden_;
is_changed = true;
}
return is_changed; return is_changed;
} }
@ -59,14 +64,14 @@ td_api::object_ptr<td_api::forumTopicInfo> ForumTopicInfo::get_forum_topic_info_
auto creator_id = get_message_sender_object_const(td, creator_dialog_id_, "get_forum_topic_info_object"); auto creator_id = get_message_sender_object_const(td, creator_dialog_id_, "get_forum_topic_info_object");
return td_api::make_object<td_api::forumTopicInfo>(top_thread_message_id_.get(), title_, return td_api::make_object<td_api::forumTopicInfo>(top_thread_message_id_.get(), title_,
icon_.get_forum_topic_icon_object(), creation_date_, icon_.get_forum_topic_icon_object(), creation_date_,
std::move(creator_id), is_outgoing_, is_closed_); std::move(creator_id), is_outgoing_, is_closed_, is_hidden_);
} }
bool operator==(const ForumTopicInfo &lhs, const ForumTopicInfo &rhs) { bool operator==(const ForumTopicInfo &lhs, const ForumTopicInfo &rhs) {
return lhs.top_thread_message_id_ == rhs.top_thread_message_id_ && lhs.title_ == rhs.title_ && return lhs.top_thread_message_id_ == rhs.top_thread_message_id_ && lhs.title_ == rhs.title_ &&
lhs.icon_ == rhs.icon_ && lhs.creation_date_ == rhs.creation_date_ && lhs.icon_ == rhs.icon_ && lhs.creation_date_ == rhs.creation_date_ &&
lhs.creator_dialog_id_ == rhs.creator_dialog_id_ && lhs.is_outgoing_ == rhs.is_outgoing_ && lhs.creator_dialog_id_ == rhs.creator_dialog_id_ && lhs.is_outgoing_ == rhs.is_outgoing_ &&
lhs.is_closed_ == rhs.is_closed_; lhs.is_closed_ == rhs.is_closed_ && lhs.is_hidden_ == rhs.is_hidden_;
} }
bool operator!=(const ForumTopicInfo &lhs, const ForumTopicInfo &rhs) { bool operator!=(const ForumTopicInfo &lhs, const ForumTopicInfo &rhs) {

View File

@ -28,6 +28,7 @@ class ForumTopicInfo {
DialogId creator_dialog_id_; DialogId creator_dialog_id_;
bool is_outgoing_ = false; bool is_outgoing_ = false;
bool is_closed_ = false; bool is_closed_ = false;
bool is_hidden_ = false;
friend bool operator==(const ForumTopicInfo &lhs, const ForumTopicInfo &rhs); friend bool operator==(const ForumTopicInfo &lhs, const ForumTopicInfo &rhs);
friend bool operator!=(const ForumTopicInfo &lhs, const ForumTopicInfo &rhs); friend bool operator!=(const ForumTopicInfo &lhs, const ForumTopicInfo &rhs);
@ -40,14 +41,15 @@ class ForumTopicInfo {
explicit ForumTopicInfo(const tl_object_ptr<telegram_api::ForumTopic> &forum_topic_ptr); explicit ForumTopicInfo(const tl_object_ptr<telegram_api::ForumTopic> &forum_topic_ptr);
ForumTopicInfo(MessageId top_thread_message_id, string title, ForumTopicIcon icon, int32 creation_date, ForumTopicInfo(MessageId top_thread_message_id, string title, ForumTopicIcon icon, int32 creation_date,
DialogId creator_dialog_id, bool is_outgoing, bool is_closed) DialogId creator_dialog_id, bool is_outgoing, bool is_closed, bool is_hidden)
: top_thread_message_id_(top_thread_message_id) : top_thread_message_id_(top_thread_message_id)
, title_(std::move(title)) , title_(std::move(title))
, icon_(std::move(icon)) , icon_(std::move(icon))
, creation_date_(creation_date) , creation_date_(creation_date)
, creator_dialog_id_(creator_dialog_id) , creator_dialog_id_(creator_dialog_id)
, is_outgoing_(is_outgoing) , is_outgoing_(is_outgoing)
, is_closed_(is_closed) { , is_closed_(is_closed)
, is_hidden_(is_hidden) {
} }
bool is_empty() const { bool is_empty() const {
@ -70,6 +72,10 @@ class ForumTopicInfo {
return is_closed_; return is_closed_;
} }
bool is_hidden() const {
return is_hidden_;
}
bool apply_edited_data(const ForumTopicEditedData &edited_data); bool apply_edited_data(const ForumTopicEditedData &edited_data);
td_api::object_ptr<td_api::forumTopicInfo> get_forum_topic_info_object(Td *td) const; td_api::object_ptr<td_api::forumTopicInfo> get_forum_topic_info_object(Td *td) const;

View File

@ -20,6 +20,7 @@ void ForumTopicInfo::store(StorerT &storer) const {
BEGIN_STORE_FLAGS(); BEGIN_STORE_FLAGS();
STORE_FLAG(is_outgoing_); STORE_FLAG(is_outgoing_);
STORE_FLAG(is_closed_); STORE_FLAG(is_closed_);
STORE_FLAG(is_hidden_);
END_STORE_FLAGS(); END_STORE_FLAGS();
td::store(top_thread_message_id_, storer); td::store(top_thread_message_id_, storer);
td::store(title_, storer); td::store(title_, storer);
@ -33,6 +34,7 @@ void ForumTopicInfo::parse(ParserT &parser) {
BEGIN_PARSE_FLAGS(); BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_outgoing_); PARSE_FLAG(is_outgoing_);
PARSE_FLAG(is_closed_); PARSE_FLAG(is_closed_);
PARSE_FLAG(is_hidden_);
END_PARSE_FLAGS(); END_PARSE_FLAGS();
td::parse(top_thread_message_id_, parser); td::parse(top_thread_message_id_, parser);
td::parse(title_, parser); td::parse(title_, parser);

View File

@ -96,7 +96,7 @@ class CreateForumTopicQuery final : public Td::ResultHandler {
auto forum_topic_info = auto forum_topic_info =
td::make_unique<ForumTopicInfo>(MessageId(ServerMessageId(service_message->id_)), action->title_, td::make_unique<ForumTopicInfo>(MessageId(ServerMessageId(service_message->id_)), action->title_,
ForumTopicIcon(action->icon_color_, action->icon_emoji_id_), ForumTopicIcon(action->icon_color_, action->icon_emoji_id_),
service_message->date_, creator_dialog_id_, true, false); service_message->date_, creator_dialog_id_, true, false, false);
td_->updates_manager_->on_get_updates( td_->updates_manager_->on_get_updates(
std::move(ptr), std::move(ptr),
PromiseCreator::lambda([dialog_id = DialogId(channel_id_), forum_topic_info = std::move(forum_topic_info), PromiseCreator::lambda([dialog_id = DialogId(channel_id_), forum_topic_info = std::move(forum_topic_info),