mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-04 11:00:46 +00:00
Initial forum support in bots data classes.
This commit is contained in:
@@ -20,6 +20,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/business/data_business_info.h"
|
||||
#include "data/components/credits.h"
|
||||
#include "data/data_cloud_themes.h"
|
||||
#include "data/data_forum.h"
|
||||
#include "data/data_forum_icons.h"
|
||||
#include "data/data_saved_music.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_changes.h"
|
||||
@@ -84,6 +86,28 @@ bool ApplyBotVerifierSettings(
|
||||
|
||||
BotInfo::BotInfo() = default;
|
||||
|
||||
BotInfo::~BotInfo() = default;
|
||||
|
||||
void BotInfo::ensureForum(not_null<UserData*> that) {
|
||||
if (!_forum) {
|
||||
const auto history = that->owner().history(that);
|
||||
_forum = std::make_unique<Data::Forum>(history);
|
||||
history->forumChanged(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
Data::Forum *BotInfo::forum() const {
|
||||
return _forum.get();
|
||||
}
|
||||
|
||||
std::unique_ptr<Data::Forum> BotInfo::takeForumData() {
|
||||
if (auto result = base::take(_forum)) {
|
||||
result->history()->forumChanged(result.get());
|
||||
return result;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Data::LastseenStatus LastseenFromMTP(
|
||||
const MTPUserStatus &status,
|
||||
Data::LastseenStatus currentStatus) {
|
||||
@@ -471,12 +495,31 @@ void UserData::setAccessHash(uint64 accessHash) {
|
||||
}
|
||||
|
||||
void UserData::setFlags(UserDataFlags which) {
|
||||
if ((which & UserDataFlag::Deleted)
|
||||
!= (flags() & UserDataFlag::Deleted)) {
|
||||
if (!isBot()) {
|
||||
which &= ~UserDataFlag::Forum;
|
||||
}
|
||||
const auto diff = flags() ^ which;
|
||||
if (diff & UserDataFlag::Deleted) {
|
||||
invalidateEmptyUserpic();
|
||||
}
|
||||
// Let Data::Forum live till the end of _flags.set.
|
||||
// That way the data can be used in changes handler.
|
||||
// Example: render frame for forum auto-closing animation.
|
||||
const auto takenForum = (botInfo
|
||||
&& (diff & Flag::Forum)
|
||||
&& !(which & Flag::Forum))
|
||||
? botInfo->takeForumData()
|
||||
: nullptr;
|
||||
if ((diff & Flag::Forum) && (which & Flag::Forum)) {
|
||||
if (const auto info = botInfo.get()) {
|
||||
info->ensureForum(this);
|
||||
}
|
||||
}
|
||||
_flags.set((flags() & UserDataFlag::Self)
|
||||
| (which & ~UserDataFlag::Self));
|
||||
if (const auto raw = takenForum.get()) {
|
||||
owner().forumIcons().clearUserpicsReset(raw);
|
||||
}
|
||||
}
|
||||
|
||||
void UserData::addFlags(UserDataFlags which) {
|
||||
|
||||
Reference in New Issue
Block a user