Allow schedule messages while in slowmode counter.

This commit is contained in:
John Preston 2019-09-02 12:03:02 +03:00
parent 66bf48e21e
commit 87ea49e094
2 changed files with 22 additions and 16 deletions

View file

@ -2920,7 +2920,7 @@ void HistoryWidget::send(Api::SendOptions options) {
} else if (_editMsgId) {
saveEditMsg();
return;
} else if (showSlowmodeError()) {
} else if (!options.scheduled && showSlowmodeError()) {
return;
}
@ -2940,7 +2940,8 @@ void HistoryWidget::send(Api::SendOptions options) {
const auto error = GetErrorTextForSending(
_peer,
_toForward,
message.textWithTags);
message.textWithTags,
options.scheduled);
if (!error.isEmpty()) {
ShowErrorToast(error);
return;
@ -2994,11 +2995,23 @@ SendMenuType HistoryWidget::sendMenuType() const {
: SendMenuType::Scheduled;
}
auto HistoryWidget::computeSendButtonType() const {
using Type = Ui::SendButton::Type;
if (_editMsgId) {
return Type::Save;
} else if (_isInlineBot) {
return Type::Cancel;
} else if (showRecordButton()) {
return Type::Record;
}
return Type::Send;
}
SendMenuType HistoryWidget::sendButtonMenuType() const {
return ((_send->type() != Ui::SendButton::Type::Send)
|| _send->isDisabled())
? SendMenuType::Disabled
: sendMenuType();
return (computeSendButtonType() == Ui::SendButton::Type::Send)
? sendMenuType()
: SendMenuType::Disabled;
}
void HistoryWidget::unblockUser() {
@ -3702,16 +3715,8 @@ bool HistoryWidget::showInlineBotCancel() const {
void HistoryWidget::updateSendButtonType() {
using Type = Ui::SendButton::Type;
const auto type = [&] {
if (_editMsgId) {
return Type::Save;
} else if (_isInlineBot) {
return Type::Cancel;
} else if (showRecordButton()) {
return Type::Record;
}
return Type::Send;
}();
const auto type = computeSendButtonType();
_send->setType(type);
const auto delay = [&] {

View file

@ -404,6 +404,7 @@ private:
void clearHighlightMessages();
void stopMessageHighlight();
auto computeSendButtonType() const;
void updateSendAction(
not_null<History*> history,
SendAction::Type type,