mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-05-30 03:33:55 +02:00
Allow fast bot mode without support mode.
This commit is contained in:
parent
3f24627f54
commit
2b8eec8666
10 changed files with 150 additions and 98 deletions
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "api/api_text_entities.h"
|
#include "api/api_text_entities.h"
|
||||||
#include "base/qt/qt_key_modifiers.h"
|
#include "base/qt/qt_key_modifiers.h"
|
||||||
|
#include "base/options.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
#include "ui/effects/spoiler_mess.h"
|
#include "ui/effects/spoiler_mess.h"
|
||||||
|
@ -63,8 +64,20 @@ namespace {
|
||||||
|
|
||||||
const auto kPsaForwardedPrefix = "cloud_lng_forwarded_psa_";
|
const auto kPsaForwardedPrefix = "cloud_lng_forwarded_psa_";
|
||||||
|
|
||||||
|
base::options::toggle FastButtonsModeOption({
|
||||||
|
.id = kOptionFastButtonsMode,
|
||||||
|
.name = "Fast buttons mode",
|
||||||
|
.description = "Trigger inline keyboard buttons by 1-9 keyboard keys.",
|
||||||
|
});
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
const char kOptionFastButtonsMode[] = "fast-buttons-mode";
|
||||||
|
|
||||||
|
bool FastButtonsMode() {
|
||||||
|
return FastButtonsModeOption.value();
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryMessageVia::create(
|
void HistoryMessageVia::create(
|
||||||
not_null<Data::Session*> owner,
|
not_null<Data::Session*> owner,
|
||||||
UserId userId) {
|
UserId userId) {
|
||||||
|
@ -924,10 +937,10 @@ void ReplyKeyboard::paint(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReplyKeyboard::hasFastButtonMode() const {
|
bool ReplyKeyboard::hasFastButtonMode() const {
|
||||||
return _item->inlineReplyKeyboard()
|
return FastButtonsMode()
|
||||||
|
&& _item->inlineReplyKeyboard()
|
||||||
&& (_item == _item->history()->lastMessage())
|
&& (_item == _item->history()->lastMessage())
|
||||||
&& _item->history()->session().supportMode()
|
&& _item->history()->session().fastButtonsBots().enabled(
|
||||||
&& _item->history()->session().supportHelper().fastButtonMode(
|
|
||||||
_item->history()->peer);
|
_item->history()->peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,9 @@ namespace style {
|
||||||
struct BotKeyboardButton;
|
struct BotKeyboardButton;
|
||||||
} // namespace style
|
} // namespace style
|
||||||
|
|
||||||
|
extern const char kOptionFastButtonsMode[];
|
||||||
|
[[nodiscard]] bool FastButtonsMode();
|
||||||
|
|
||||||
struct HistoryMessageVia : public RuntimeComponent<HistoryMessageVia, HistoryItem> {
|
struct HistoryMessageVia : public RuntimeComponent<HistoryMessageVia, HistoryItem> {
|
||||||
void create(not_null<Data::Session*> owner, UserId userId);
|
void create(not_null<Data::Session*> owner, UserId userId);
|
||||||
void resize(int32 availw) const;
|
void resize(int32 availw) const;
|
||||||
|
|
|
@ -2911,14 +2911,12 @@ void HistoryWidget::refreshSilentToggle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::setupFastButtonMode() {
|
void HistoryWidget::setupFastButtonMode() {
|
||||||
if (!session().supportMode()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto field = _field->rawTextEdit();
|
const auto field = _field->rawTextEdit();
|
||||||
base::install_event_filter(field, [=](not_null<QEvent*> e) {
|
base::install_event_filter(field, [=](not_null<QEvent*> e) {
|
||||||
if (e->type() != QEvent::KeyPress
|
if (e->type() != QEvent::KeyPress
|
||||||
|| !_history
|
|| !_history
|
||||||
|| !session().supportHelper().fastButtonMode(_history->peer)
|
|| !FastButtonsMode()
|
||||||
|
|| !session().fastButtonsBots().enabled(_history->peer)
|
||||||
|| !_field->getLastText().isEmpty()) {
|
|| !_field->getLastText().isEmpty()) {
|
||||||
return base::EventFilterResult::Continue;
|
return base::EventFilterResult::Continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "dialogs/ui/dialogs_message_view.h"
|
#include "dialogs/ui/dialogs_message_view.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
|
#include "history/history_item_components.h"
|
||||||
#include "history/history_item_helpers.h"
|
#include "history/history_item_helpers.h"
|
||||||
#include "history/view/history_view_item_preview.h"
|
#include "history/view/history_view_item_preview.h"
|
||||||
#include "info/bot/earn/info_bot_earn_widget.h"
|
#include "info/bot/earn/info_bot_earn_widget.h"
|
||||||
|
@ -2360,7 +2361,7 @@ void ActionsFiller::addDeleteContactAction(not_null<UserData*> user) {
|
||||||
void ActionsFiller::addFastButtonsMode(not_null<UserData*> user) {
|
void ActionsFiller::addFastButtonsMode(not_null<UserData*> user) {
|
||||||
Expects(user->isBot());
|
Expects(user->isBot());
|
||||||
|
|
||||||
const auto helper = &user->session().supportHelper();
|
const auto bots = &user->session().fastButtonsBots();
|
||||||
const auto button = _wrap->add(object_ptr<Ui::SettingsButton>(
|
const auto button = _wrap->add(object_ptr<Ui::SettingsButton>(
|
||||||
_wrap,
|
_wrap,
|
||||||
rpl::single(u"Fast buttons mode"_q),
|
rpl::single(u"Fast buttons mode"_q),
|
||||||
|
@ -2374,17 +2375,17 @@ void ActionsFiller::addFastButtonsMode(not_null<UserData*> user) {
|
||||||
AddDivider(_wrap);
|
AddDivider(_wrap);
|
||||||
AddSkip(_wrap);
|
AddSkip(_wrap);
|
||||||
|
|
||||||
button->toggleOn(helper->fastButtonModeValue(user));
|
button->toggleOn(bots->enabledValue(user));
|
||||||
button->toggledValue(
|
button->toggledValue(
|
||||||
) | rpl::filter([=](bool value) {
|
) | rpl::filter([=](bool value) {
|
||||||
return value != helper->fastButtonMode(user);
|
return value != bots->enabled(user);
|
||||||
}) | rpl::start_with_next([=](bool value) {
|
}) | rpl::start_with_next([=](bool value) {
|
||||||
helper->setFastButtonMode(user, value);
|
bots->setEnabled(user, value);
|
||||||
}, button->lifetime());
|
}, button->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionsFiller::addBotCommandActions(not_null<UserData*> user) {
|
void ActionsFiller::addBotCommandActions(not_null<UserData*> user) {
|
||||||
if (user->session().supportMode()) {
|
if (FastButtonsMode()) {
|
||||||
addFastButtonsMode(user);
|
addFastButtonsMode(user);
|
||||||
}
|
}
|
||||||
const auto window = _controller->parentController();
|
const auto window = _controller->parentController();
|
||||||
|
|
|
@ -119,6 +119,7 @@ Session::Session(
|
||||||
, _credits(std::make_unique<Data::Credits>(this))
|
, _credits(std::make_unique<Data::Credits>(this))
|
||||||
, _cachedReactionIconFactory(std::make_unique<ReactionIconFactory>())
|
, _cachedReactionIconFactory(std::make_unique<ReactionIconFactory>())
|
||||||
, _supportHelper(Support::Helper::Create(this))
|
, _supportHelper(Support::Helper::Create(this))
|
||||||
|
, _fastButtonsBots(std::make_unique<Support::FastButtonsBots>(this))
|
||||||
, _saveSettingsTimer([=] { saveSettings(); }) {
|
, _saveSettingsTimer([=] { saveSettings(); }) {
|
||||||
Expects(_settings != nullptr);
|
Expects(_settings != nullptr);
|
||||||
|
|
||||||
|
@ -426,6 +427,10 @@ Support::Templates& Session::supportTemplates() const {
|
||||||
return supportHelper().templates();
|
return supportHelper().templates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Support::FastButtonsBots &Session::fastButtonsBots() const {
|
||||||
|
return *_fastButtonsBots;
|
||||||
|
}
|
||||||
|
|
||||||
void Session::addWindow(not_null<Window::SessionController*> controller) {
|
void Session::addWindow(not_null<Window::SessionController*> controller) {
|
||||||
_windows.emplace(controller);
|
_windows.emplace(controller);
|
||||||
controller->lifetime().add([=] {
|
controller->lifetime().add([=] {
|
||||||
|
|
|
@ -26,6 +26,7 @@ struct ConfigFields;
|
||||||
namespace Support {
|
namespace Support {
|
||||||
class Helper;
|
class Helper;
|
||||||
class Templates;
|
class Templates;
|
||||||
|
class FastButtonsBots;
|
||||||
} // namespace Support
|
} // namespace Support
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
@ -233,6 +234,7 @@ public:
|
||||||
[[nodiscard]] bool supportMode() const;
|
[[nodiscard]] bool supportMode() const;
|
||||||
[[nodiscard]] Support::Helper &supportHelper() const;
|
[[nodiscard]] Support::Helper &supportHelper() const;
|
||||||
[[nodiscard]] Support::Templates &supportTemplates() const;
|
[[nodiscard]] Support::Templates &supportTemplates() const;
|
||||||
|
[[nodiscard]] Support::FastButtonsBots &fastButtonsBots() const;
|
||||||
|
|
||||||
[[nodiscard]] auto colorIndicesValue()
|
[[nodiscard]] auto colorIndicesValue()
|
||||||
-> rpl::producer<Ui::ColorIndicesCompressed>;
|
-> rpl::producer<Ui::ColorIndicesCompressed>;
|
||||||
|
@ -275,6 +277,7 @@ private:
|
||||||
const std::unique_ptr<ReactionIconFactory> _cachedReactionIconFactory;
|
const std::unique_ptr<ReactionIconFactory> _cachedReactionIconFactory;
|
||||||
|
|
||||||
const std::unique_ptr<Support::Helper> _supportHelper;
|
const std::unique_ptr<Support::Helper> _supportHelper;
|
||||||
|
const std::unique_ptr<Support::FastButtonsBots> _fastButtonsBots;
|
||||||
|
|
||||||
std::shared_ptr<QImage> _selfUserpicView;
|
std::shared_ptr<QImage> _selfUserpicView;
|
||||||
rpl::variable<bool> _premiumPossible = false;
|
rpl::variable<bool> _premiumPossible = false;
|
||||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_cloud_themes.h"
|
#include "data/data_cloud_themes.h"
|
||||||
|
#include "history/history_item_components.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_domain.h"
|
#include "main/main_domain.h"
|
||||||
|
@ -28,9 +29,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "media/audio/media_audio_track.h"
|
#include "media/audio/media_audio_track.h"
|
||||||
#include "settings/settings_folders.h"
|
#include "settings/settings_folders.h"
|
||||||
|
#include "storage/storage_account.h"
|
||||||
#include "api/api_updates.h"
|
#include "api/api_updates.h"
|
||||||
#include "base/qt/qt_common_adapters.h"
|
#include "base/qt/qt_common_adapters.h"
|
||||||
#include "base/custom_app_icon.h"
|
#include "base/custom_app_icon.h"
|
||||||
|
#include "base/options.h"
|
||||||
#include "boxes/abstract_box.h" // Ui::show().
|
#include "boxes/abstract_box.h" // Ui::show().
|
||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
@ -165,6 +168,15 @@ auto GenerateCodes() {
|
||||||
Core::Application::RegisterUrlScheme();
|
Core::Application::RegisterUrlScheme();
|
||||||
Ui::Toast::Show("Forced custom scheme register.");
|
Ui::Toast::Show("Forced custom scheme register.");
|
||||||
});
|
});
|
||||||
|
codes.emplace(u"numberbuttons"_q, [](SessionController *window) {
|
||||||
|
using namespace base::options;
|
||||||
|
auto &option = lookup<bool>(kOptionFastButtonsMode);
|
||||||
|
const auto now = !option.value();
|
||||||
|
option.set(now);
|
||||||
|
Ui::Toast::Show(now
|
||||||
|
? u"Fast buttons mode enabled."_q
|
||||||
|
: u"Fast buttons mode disabled."_q);
|
||||||
|
});
|
||||||
|
|
||||||
auto audioFilters = u"Audio files (*.wav *.mp3);;"_q + FileDialog::AllFilesFilter();
|
auto audioFilters = u"Audio files (*.wav *.mp3);;"_q + FileDialog::AllFilesFilter();
|
||||||
auto audioKeys = {
|
auto audioKeys = {
|
||||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/launcher.h"
|
#include "core/launcher.h"
|
||||||
#include "chat_helpers/tabbed_panel.h"
|
#include "chat_helpers/tabbed_panel.h"
|
||||||
#include "dialogs/dialogs_widget.h"
|
#include "dialogs/dialogs_widget.h"
|
||||||
|
#include "history/history_item_components.h"
|
||||||
#include "info/profile/info_profile_actions.h"
|
#include "info/profile/info_profile_actions.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -158,6 +159,9 @@ void SetupExperimental(
|
||||||
addToggle(Data::kOptionExternalVideoPlayer);
|
addToggle(Data::kOptionExternalVideoPlayer);
|
||||||
addToggle(Window::kOptionNewWindowsSizeAsFirst);
|
addToggle(Window::kOptionNewWindowsSizeAsFirst);
|
||||||
addToggle(MTP::details::kOptionPreferIPv6);
|
addToggle(MTP::details::kOptionPreferIPv6);
|
||||||
|
if (base::options::lookup<bool>(kOptionFastButtonsMode).value()) {
|
||||||
|
addToggle(kOptionFastButtonsMode);
|
||||||
|
}
|
||||||
addToggle(Window::kOptionDisableTouchbar);
|
addToggle(Window::kOptionDisableTouchbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -483,79 +483,6 @@ UserInfo Helper::infoCurrent(not_null<UserData*> user) const {
|
||||||
return (i != end(_userInformation)) ? i->second : UserInfo();
|
return (i != end(_userInformation)) ? i->second : UserInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Helper::readFastButtonModeBots() {
|
|
||||||
_readFastButtonModeBots = true;
|
|
||||||
|
|
||||||
auto f = QFile(FastButtonModeIdsPath(_session));
|
|
||||||
if (!f.open(QIODevice::ReadOnly)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto data = f.readAll();
|
|
||||||
const auto json = QJsonDocument::fromJson(data);
|
|
||||||
if (!json.isObject()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto object = json.object();
|
|
||||||
const auto array = object.value(u"ids"_q).toArray();
|
|
||||||
for (const auto &value : array) {
|
|
||||||
const auto bareId = value.toString().toULongLong();
|
|
||||||
_fastButtonModeBots.emplace(PeerId(bareId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Helper::writeFastButtonModeBots() {
|
|
||||||
auto array = QJsonArray();
|
|
||||||
for (const auto &id : _fastButtonModeBots) {
|
|
||||||
array.append(QString::number(id.value));
|
|
||||||
}
|
|
||||||
auto object = QJsonObject();
|
|
||||||
object[u"ids"_q] = array;
|
|
||||||
auto f = QFile(FastButtonModeIdsPath(_session));
|
|
||||||
if (f.open(QIODevice::WriteOnly)) {
|
|
||||||
f.write(QJsonDocument(object).toJson(QJsonDocument::Indented));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Helper::fastButtonMode(not_null<PeerData*> peer) const {
|
|
||||||
if (!_readFastButtonModeBots) {
|
|
||||||
const_cast<Helper*>(this)->readFastButtonModeBots();
|
|
||||||
}
|
|
||||||
return _fastButtonModeBots.contains(peer->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl::producer<bool> Helper::fastButtonModeValue(
|
|
||||||
not_null<PeerData*> peer) const {
|
|
||||||
return rpl::single(
|
|
||||||
fastButtonMode(peer)
|
|
||||||
) | rpl::then(_fastButtonModeBotsChanges.events(
|
|
||||||
) | rpl::filter([=](PeerId id) {
|
|
||||||
return (peer->id == id);
|
|
||||||
}) | rpl::map([=] {
|
|
||||||
return fastButtonMode(peer);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Helper::setFastButtonMode(not_null<PeerData*> peer, bool fast) {
|
|
||||||
if (fast == fastButtonMode(peer)) {
|
|
||||||
return;
|
|
||||||
} else if (fast) {
|
|
||||||
_fastButtonModeBots.emplace(peer->id);
|
|
||||||
} else {
|
|
||||||
_fastButtonModeBots.remove(peer->id);
|
|
||||||
}
|
|
||||||
if (_fastButtonModeBots.empty()) {
|
|
||||||
QFile(FastButtonModeIdsPath(_session)).remove();
|
|
||||||
} else {
|
|
||||||
writeFastButtonModeBots();
|
|
||||||
}
|
|
||||||
_fastButtonModeBotsChanges.fire_copy(peer->id);
|
|
||||||
if (const auto history = peer->owner().history(peer)) {
|
|
||||||
if (const auto item = history->lastMessage()) {
|
|
||||||
history->owner().requestItemRepaint(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Helper::editInfo(
|
void Helper::editInfo(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<UserData*> user) {
|
not_null<UserData*> user) {
|
||||||
|
@ -624,6 +551,83 @@ Templates &Helper::templates() {
|
||||||
return _templates;
|
return _templates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FastButtonsBots::FastButtonsBots(not_null<Main::Session*> session)
|
||||||
|
: _session(session) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FastButtonsBots::enabled(not_null<PeerData*> peer) const {
|
||||||
|
if (!_read) {
|
||||||
|
const_cast<FastButtonsBots*>(this)->read();
|
||||||
|
}
|
||||||
|
return _bots.contains(peer->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<bool> FastButtonsBots::enabledValue(
|
||||||
|
not_null<PeerData*> peer) const {
|
||||||
|
return rpl::single(
|
||||||
|
enabled(peer)
|
||||||
|
) | rpl::then(_changes.events(
|
||||||
|
) | rpl::filter([=](PeerId id) {
|
||||||
|
return (peer->id == id);
|
||||||
|
}) | rpl::map([=] {
|
||||||
|
return enabled(peer);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FastButtonsBots::setEnabled(not_null<PeerData*> peer, bool value) {
|
||||||
|
if (value == enabled(peer)) {
|
||||||
|
return;
|
||||||
|
} else if (value) {
|
||||||
|
_bots.emplace(peer->id);
|
||||||
|
} else {
|
||||||
|
_bots.remove(peer->id);
|
||||||
|
}
|
||||||
|
if (_bots.empty()) {
|
||||||
|
QFile(FastButtonModeIdsPath(_session)).remove();
|
||||||
|
} else {
|
||||||
|
write();
|
||||||
|
}
|
||||||
|
_changes.fire_copy(peer->id);
|
||||||
|
if (const auto history = peer->owner().history(peer)) {
|
||||||
|
if (const auto item = history->lastMessage()) {
|
||||||
|
history->owner().requestItemRepaint(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FastButtonsBots::write() {
|
||||||
|
auto array = QJsonArray();
|
||||||
|
for (const auto &id : _bots) {
|
||||||
|
array.append(QString::number(id.value));
|
||||||
|
}
|
||||||
|
auto object = QJsonObject();
|
||||||
|
object[u"ids"_q] = array;
|
||||||
|
auto f = QFile(FastButtonModeIdsPath(_session));
|
||||||
|
if (f.open(QIODevice::WriteOnly)) {
|
||||||
|
f.write(QJsonDocument(object).toJson(QJsonDocument::Indented));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FastButtonsBots::read() {
|
||||||
|
_read = true;
|
||||||
|
|
||||||
|
auto f = QFile(FastButtonModeIdsPath(_session));
|
||||||
|
if (!f.open(QIODevice::ReadOnly)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto data = f.readAll();
|
||||||
|
const auto json = QJsonDocument::fromJson(data);
|
||||||
|
if (!json.isObject()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto object = json.object();
|
||||||
|
const auto array = object.value(u"ids"_q).toArray();
|
||||||
|
for (const auto &value : array) {
|
||||||
|
const auto bareId = value.toString().toULongLong();
|
||||||
|
_bots.emplace(PeerId(bareId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString ChatOccupiedString(not_null<History*> history) {
|
QString ChatOccupiedString(not_null<History*> history) {
|
||||||
const auto hand = QString::fromUtf8("\xe2\x9c\x8b\xef\xb8\x8f");
|
const auto hand = QString::fromUtf8("\xe2\x9c\x8b\xef\xb8\x8f");
|
||||||
const auto name = ParseOccupationName(history);
|
const auto name = ParseOccupationName(history);
|
||||||
|
|
|
@ -65,11 +65,6 @@ public:
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<UserData*> user);
|
not_null<UserData*> user);
|
||||||
|
|
||||||
[[nodiscard]] bool fastButtonMode(not_null<PeerData*> peer) const;
|
|
||||||
[[nodiscard]] rpl::producer<bool> fastButtonModeValue(
|
|
||||||
not_null<PeerData*> peer) const;
|
|
||||||
void setFastButtonMode(not_null<PeerData*> peer, bool fast);
|
|
||||||
|
|
||||||
Templates &templates();
|
Templates &templates();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -97,10 +92,7 @@ private:
|
||||||
TextWithEntities text,
|
TextWithEntities text,
|
||||||
Fn<void(bool success)> done);
|
Fn<void(bool success)> done);
|
||||||
|
|
||||||
void writeFastButtonModeBots();
|
const not_null<Main::Session*> _session;
|
||||||
void readFastButtonModeBots();
|
|
||||||
|
|
||||||
not_null<Main::Session*> _session;
|
|
||||||
MTP::Sender _api;
|
MTP::Sender _api;
|
||||||
Templates _templates;
|
Templates _templates;
|
||||||
QString _supportName;
|
QString _supportName;
|
||||||
|
@ -117,14 +109,31 @@ private:
|
||||||
base::weak_ptr<Window::SessionController>> _userInfoEditPending;
|
base::weak_ptr<Window::SessionController>> _userInfoEditPending;
|
||||||
base::flat_map<not_null<UserData*>, SavingInfo> _userInfoSaving;
|
base::flat_map<not_null<UserData*>, SavingInfo> _userInfoSaving;
|
||||||
|
|
||||||
base::flat_set<PeerId> _fastButtonModeBots;
|
|
||||||
rpl::event_stream<PeerId> _fastButtonModeBotsChanges;
|
|
||||||
bool _readFastButtonModeBots = false;
|
|
||||||
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FastButtonsBots final {
|
||||||
|
public:
|
||||||
|
explicit FastButtonsBots(not_null<Main::Session*> session);
|
||||||
|
|
||||||
|
[[nodiscard]] bool enabled(not_null<PeerData*> peer) const;
|
||||||
|
[[nodiscard]] rpl::producer<bool> enabledValue(
|
||||||
|
not_null<PeerData*> peer) const;
|
||||||
|
void setEnabled(not_null<PeerData*> peer, bool value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void write();
|
||||||
|
void read();
|
||||||
|
|
||||||
|
const not_null<Main::Session*> _session;
|
||||||
|
|
||||||
|
base::flat_set<PeerId> _bots;
|
||||||
|
rpl::event_stream<PeerId> _changes;
|
||||||
|
bool _read = false;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
QString ChatOccupiedString(not_null<History*> history);
|
QString ChatOccupiedString(not_null<History*> history);
|
||||||
|
|
||||||
QString InterpretSendPath(
|
QString InterpretSendPath(
|
||||||
|
|
Loading…
Add table
Reference in a new issue