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

View File

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