mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Remove some usages of App::main().
This commit is contained in:
@@ -94,6 +94,7 @@ void CheckForSwitchInlineButton(not_null<HistoryItem*> item) {
|
||||
using ButtonType = HistoryMessageMarkupButton::Type;
|
||||
if (button.type == ButtonType::SwitchInline) {
|
||||
Notify::switchInlineBotButtonReceived(
|
||||
&item->history()->session(),
|
||||
QString::fromUtf8(button.data));
|
||||
return;
|
||||
}
|
||||
@@ -889,6 +890,25 @@ void Session::chatsListDone(Data::Folder *folder) {
|
||||
_chatsListLoadedEvents.fire_copy(folder);
|
||||
}
|
||||
|
||||
void Session::userIsBotChanged(not_null<UserData*> user) {
|
||||
if (const auto history = this->history(user)) {
|
||||
chatsFilters().refreshHistory(history);
|
||||
}
|
||||
_userIsBotChanges.fire_copy(user);
|
||||
}
|
||||
|
||||
rpl::producer<not_null<UserData*>> Session::userIsBotChanges() const {
|
||||
return _userIsBotChanges.events();
|
||||
}
|
||||
|
||||
void Session::botCommandsChanged(not_null<UserData*> user) {
|
||||
_botCommandsChanges.fire_copy(user);
|
||||
}
|
||||
|
||||
rpl::producer<not_null<UserData*>> Session::botCommandsChanges() const {
|
||||
return _botCommandsChanges.events();
|
||||
}
|
||||
|
||||
Storage::Cache::Database &Session::cache() {
|
||||
return *_cache;
|
||||
}
|
||||
|
@@ -200,6 +200,11 @@ public:
|
||||
void chatsListChanged(Data::Folder *folder);
|
||||
void chatsListDone(Data::Folder *folder);
|
||||
|
||||
void userIsBotChanged(not_null<UserData*> user);
|
||||
[[nodiscard]] rpl::producer<not_null<UserData*>> userIsBotChanges() const;
|
||||
void botCommandsChanged(not_null<UserData*> user);
|
||||
[[nodiscard]] rpl::producer<not_null<UserData*>> botCommandsChanges() const;
|
||||
|
||||
struct ItemVisibilityQuery {
|
||||
not_null<HistoryItem*> item;
|
||||
not_null<bool*> isVisible;
|
||||
@@ -771,6 +776,8 @@ private:
|
||||
rpl::variable<bool> _contactsLoaded = false;
|
||||
rpl::event_stream<Data::Folder*> _chatsListLoadedEvents;
|
||||
rpl::event_stream<Data::Folder*> _chatsListChanged;
|
||||
rpl::event_stream<not_null<UserData*>> _userIsBotChanges;
|
||||
rpl::event_stream<not_null<UserData*>> _botCommandsChanges;
|
||||
base::Observable<ItemVisibilityQuery> _queryItemVisibility;
|
||||
rpl::event_stream<IdChange> _itemIdChanges;
|
||||
rpl::event_stream<not_null<const HistoryItem*>> _itemLayoutChanges;
|
||||
|
@@ -131,22 +131,15 @@ void UserData::setPhone(const QString &newPhone) {
|
||||
|
||||
void UserData::setBotInfoVersion(int version) {
|
||||
if (version < 0) {
|
||||
if (botInfo) {
|
||||
if (!botInfo->commands.isEmpty()) {
|
||||
botInfo->commands.clear();
|
||||
Notify::botCommandsChanged(this);
|
||||
}
|
||||
botInfo = nullptr;
|
||||
Notify::userIsBotChanged(this);
|
||||
}
|
||||
// We don't support bots becoming non-bots.
|
||||
} else if (!botInfo) {
|
||||
botInfo = std::make_unique<BotInfo>();
|
||||
botInfo->version = version;
|
||||
Notify::userIsBotChanged(this);
|
||||
owner().userIsBotChanged(this);
|
||||
} else if (botInfo->version < version) {
|
||||
if (!botInfo->commands.isEmpty()) {
|
||||
botInfo->commands.clear();
|
||||
Notify::botCommandsChanged(this);
|
||||
owner().botCommandsChanged(this);
|
||||
}
|
||||
botInfo->description.clear();
|
||||
botInfo->version = version;
|
||||
@@ -199,7 +192,7 @@ void UserData::setBotInfo(const MTPBotInfo &info) {
|
||||
botInfo->inited = true;
|
||||
|
||||
if (changedCommands) {
|
||||
Notify::botCommandsChanged(this);
|
||||
owner().botCommandsChanged(this);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user