mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-05-14 14:15:31 +00:00
Fix toggling chatbot replying, fix saving.
This commit is contained in:
parent
72770aa76d
commit
29dd574e22
@ -125,8 +125,10 @@ void Chatbots::togglePaused(not_null<PeerData*> peer, bool paused) {
|
|||||||
return;
|
return;
|
||||||
} else if (const auto settings = peer->barSettings()) {
|
} else if (const auto settings = peer->barSettings()) {
|
||||||
peer->setBarSettings(paused
|
peer->setBarSettings(paused
|
||||||
? (*settings | PeerBarSetting::BusinessBotPaused)
|
? ((*settings | PeerBarSetting::BusinessBotPaused)
|
||||||
: (*settings & ~PeerBarSetting::BusinessBotPaused));
|
& ~PeerBarSetting::BusinessBotCanReply)
|
||||||
|
: ((*settings & ~PeerBarSetting::BusinessBotPaused)
|
||||||
|
| PeerBarSetting::BusinessBotCanReply));
|
||||||
} else {
|
} else {
|
||||||
api->requestPeerSettings(peer);
|
api->requestPeerSettings(peer);
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,13 @@ auto RecipientsFlags(const BusinessRecipients &data) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
BusinessRecipients BusinessRecipients::MakeValid(BusinessRecipients value) {
|
||||||
|
if (value.included.empty()) {
|
||||||
|
value.allButExcluded = true;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
MTPInputBusinessRecipients ForMessagesToMTP(const BusinessRecipients &data) {
|
MTPInputBusinessRecipients ForMessagesToMTP(const BusinessRecipients &data) {
|
||||||
using Flag = MTPDinputBusinessRecipients::Flag;
|
using Flag = MTPDinputBusinessRecipients::Flag;
|
||||||
const auto &chats = data.allButExcluded ? data.excluded : data.included;
|
const auto &chats = data.allButExcluded ? data.excluded : data.included;
|
||||||
|
@ -44,6 +44,9 @@ struct BusinessRecipients {
|
|||||||
BusinessChats excluded;
|
BusinessChats excluded;
|
||||||
bool allButExcluded = false;
|
bool allButExcluded = false;
|
||||||
|
|
||||||
|
[[nodiscard]] static BusinessRecipients MakeValid(
|
||||||
|
BusinessRecipients value);
|
||||||
|
|
||||||
friend inline bool operator==(
|
friend inline bool operator==(
|
||||||
const BusinessRecipients &a,
|
const BusinessRecipients &a,
|
||||||
const BusinessRecipients &b) = default;
|
const BusinessRecipients &b) = default;
|
||||||
|
@ -902,15 +902,15 @@ void BusinessBotStatus::Bar::showState(State state) {
|
|||||||
_userpic->setAttribute(Qt::WA_TransparentForMouseEvents);
|
_userpic->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
_userpic->show();
|
_userpic->show();
|
||||||
_name->setText(state.bot->name());
|
_name->setText(state.bot->name());
|
||||||
_status->setText(!state.canReply
|
_status->setText(state.paused
|
||||||
? tr::lng_chatbot_status_views(tr::now)
|
|
||||||
: state.paused
|
|
||||||
? tr::lng_chatbot_status_paused(tr::now)
|
? tr::lng_chatbot_status_paused(tr::now)
|
||||||
: tr::lng_chatbot_status_can_reply(tr::now));
|
: state.canReply
|
||||||
|
? tr::lng_chatbot_status_can_reply(tr::now)
|
||||||
|
: tr::lng_chatbot_status_views(tr::now));
|
||||||
_togglePaused->setText(state.paused
|
_togglePaused->setText(state.paused
|
||||||
? tr::lng_chatbot_button_resume()
|
? tr::lng_chatbot_button_resume()
|
||||||
: tr::lng_chatbot_button_pause());
|
: tr::lng_chatbot_button_pause());
|
||||||
_togglePaused->setVisible(state.canReply);
|
_togglePaused->setVisible(state.canReply || state.paused);
|
||||||
_paused = state.paused;
|
_paused = state.paused;
|
||||||
resizeToWidth(width());
|
resizeToWidth(width());
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ void AwayMessage::setupContent(
|
|||||||
|
|
||||||
_recipients = disabled
|
_recipients = disabled
|
||||||
? Data::BusinessRecipients{ .allButExcluded = true }
|
? Data::BusinessRecipients{ .allButExcluded = true }
|
||||||
: current.recipients;
|
: Data::BusinessRecipients::MakeValid(current.recipients);
|
||||||
auto initialSchedule = disabled ? AwaySchedule{
|
auto initialSchedule = disabled ? AwaySchedule{
|
||||||
.type = AwayScheduleType::Always,
|
.type = AwayScheduleType::Always,
|
||||||
} : current.schedule;
|
} : current.schedule;
|
||||||
|
@ -408,7 +408,7 @@ void Chatbots::setupContent(
|
|||||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||||
const auto current = controller->session().data().chatbots().current();
|
const auto current = controller->session().data().chatbots().current();
|
||||||
|
|
||||||
_recipients = current.recipients;
|
_recipients = Data::BusinessRecipients::MakeValid(current.recipients);
|
||||||
_repliesAllowed = current.repliesAllowed;
|
_repliesAllowed = current.repliesAllowed;
|
||||||
|
|
||||||
AddDividerTextWithLottie(content, {
|
AddDividerTextWithLottie(content, {
|
||||||
|
@ -125,7 +125,7 @@ void Greeting::setupContent(
|
|||||||
|
|
||||||
_recipients = disabled
|
_recipients = disabled
|
||||||
? Data::BusinessRecipients{ .allButExcluded = true }
|
? Data::BusinessRecipients{ .allButExcluded = true }
|
||||||
: current.recipients;
|
: Data::BusinessRecipients::MakeValid(current.recipients);
|
||||||
_noActivityDays = disabled
|
_noActivityDays = disabled
|
||||||
? kDefaultNoActivityDays
|
? kDefaultNoActivityDays
|
||||||
: current.noActivityDays;
|
: current.noActivityDays;
|
||||||
|
Loading…
Reference in New Issue
Block a user