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