silent broadcast done

This commit is contained in:
John Preston 2016-02-25 19:19:54 +03:00
parent 1313cd1a33
commit 2b6e30bcb5
17 changed files with 257 additions and 78 deletions

View File

@ -564,7 +564,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"lng_forwarded" = "Forwarded from {user}";
"lng_forwarded_channel" = "Forwarded from {channel}";
"lng_forwarded_via" = "Forwarded from {user} via {inline_bot}";
"lng_forwarded_via" = "Forwarded from {channel} via {inline_bot}";
"lng_forwarded_channel_via" = "Forwarded from {channel} via {inline_bot}";
"lng_forwarded_signed" = "{channel} ({user})";
"lng_in_reply_to" = "In reply to";

View File

@ -1395,7 +1395,7 @@ broadcastToggle: flatCheckbox {
bgColor: white;
disColor: black;
width: 36px;
width: 34px;
height: 46px;
duration: 200;
bgFunc: transition(easeOutCirc);
@ -1410,7 +1410,17 @@ broadcastToggle: flatCheckbox {
disImageRect: sprite(18px, 125px, 22px, 21px);
chkDisImageRect: sprite(18px, 125px, 22px, 21px);
imagePos: point(7px, 12px);
imagePos: point(6px, 12px);
}
silentToggle: flatCheckbox(broadcastToggle) {
width: 33px;
imageRect: sprite(354px, 242px, 21px, 21px);
chkImageRect: sprite(354px, 221px, 21px, 21px);
overImageRect: sprite(375px, 242px, 21px, 21px);
chkOverImageRect: sprite(375px, 221px, 21px, 21px);
disImageRect: sprite(354px, 242px, 21px, 21px);
chkDisImageRect: sprite(354px, 221px, 21px, 21px);
}
btnRecordAudio: sprite(379px, 390px, 16px, 24px);
btnRecordAudioActive: sprite(379px, 366px, 16px, 24px);

View File

@ -1051,8 +1051,8 @@ void AppClass::checkMapVersion() {
if (Local::oldMapVersion() < AppVersion) {
if (Local::oldMapVersion()) {
QString versionFeatures;
if ((cDevVersion() || cBetaVersion()) && Local::oldMapVersion() < 9025) {
versionFeatures = QString::fromUtf8("\xe2\x80\x94 Adaptive layout for wide screens switch added to Settings\n\xe2\x80\x94 Linux version crash fix");// .replace('@', qsl("@") + QChar(0x200D));
if ((cDevVersion() || cBetaVersion()) && Local::oldMapVersion() < 9027) {
versionFeatures = QString::fromUtf8("\xe2\x80\x94 Edit your messages in channels and supergroups.\n\xe2\x80\x94 Share links to specific posts in channels via the post context menu.\n\xe2\x80\x94 Add admin signatures to messages in channels.\n\xe2\x80\x94 Send silent messages in channels that will not notify members. Useful for non-urgent or late night posting.");// .replace('@', qsl("@") + QChar(0x200D));
} else if (Local::oldMapVersion() < 9026) {
versionFeatures = lang(lng_new_version_text).trimmed();
} else {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 KiB

After

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 KiB

After

Width:  |  Height:  |  Size: 242 KiB

View File

@ -417,7 +417,7 @@ EditCaptionBox::EditCaptionBox(HistoryItem *msg) : AbstractBox(st::boxWideWidth)
}
caption = media->getCaption();
}
if (!_animated && (dimensions.isEmpty() || doc) || image->isNull()) {
if ((!_animated && (dimensions.isEmpty() || doc)) || image->isNull()) {
_animated = false;
if (image->isNull()) {
_thumbw = 0;

View File

@ -651,7 +651,7 @@ void DialogsInner::onContextProfile() {
void DialogsInner::onContextToggleNotifications() {
if (!_menuPeer) return;
App::main()->updateNotifySetting(_menuPeer, menuPeerMuted());
App::main()->updateNotifySetting(_menuPeer, menuPeerMuted() ? NotifySettingSetNotify : NotifySettingSetMuted);
}
void DialogsInner::onContextSearch() {

View File

@ -140,17 +140,18 @@ void FileUploader::sendNext() {
if (parts.isEmpty()) {
if (i->docSentParts >= i->docPartsCount) {
if (requestsSent.isEmpty() && docRequestsSent.isEmpty()) {
bool silent = i->file && i->file->to.silent;
if (i->type() == PreparePhoto) {
emit photoReady(uploading, MTP_inputFile(MTP_long(i->id()), MTP_int(i->partsCount), MTP_string(i->filename()), MTP_string(i->file ? i->file->filemd5 : i->media.jpeg_md5)));
emit photoReady(uploading, silent, MTP_inputFile(MTP_long(i->id()), MTP_int(i->partsCount), MTP_string(i->filename()), MTP_string(i->file ? i->file->filemd5 : i->media.jpeg_md5)));
} else if (i->type() == PrepareDocument || i->type() == PrepareAudio) {
QByteArray docMd5(32, Qt::Uninitialized);
hashMd5Hex(i->md5Hash.result(), docMd5.data());
MTPInputFile doc = (i->docSize > UseBigFilesFrom) ? MTP_inputFileBig(MTP_long(i->id()), MTP_int(i->docPartsCount), MTP_string(i->filename())) : MTP_inputFile(MTP_long(i->id()), MTP_int(i->docPartsCount), MTP_string(i->filename()), MTP_string(docMd5));
if (i->partsCount) {
emit thumbDocumentReady(uploading, doc, MTP_inputFile(MTP_long(i->thumbId()), MTP_int(i->partsCount), MTP_string(i->file ? i->file->thumbname : (qsl("thumb.") + i->media.thumbExt)), MTP_string(i->file ? i->file->thumbmd5 : i->media.jpeg_md5)));
emit thumbDocumentReady(uploading, silent, doc, MTP_inputFile(MTP_long(i->thumbId()), MTP_int(i->partsCount), MTP_string(i->file ? i->file->thumbname : (qsl("thumb.") + i->media.thumbExt)), MTP_string(i->file ? i->file->thumbmd5 : i->media.jpeg_md5)));
} else {
emit documentReady(uploading, doc);
emit documentReady(uploading, silent, doc);
}
}
queue.remove(uploading);

View File

@ -48,9 +48,9 @@ public slots:
signals:
void photoReady(const FullMsgId &msgId, const MTPInputFile &file);
void documentReady(const FullMsgId &msgId, const MTPInputFile &file);
void thumbDocumentReady(const FullMsgId &msgId, const MTPInputFile &file, const MTPInputFile &thumb);
void photoReady(const FullMsgId &msgId, bool silent, const MTPInputFile &file);
void documentReady(const FullMsgId &msgId, bool silent, const MTPInputFile &file);
void thumbDocumentReady(const FullMsgId &msgId, bool silent, const MTPInputFile &file, const MTPInputFile &thumb);
void photoProgress(const FullMsgId &msgId);
void documentProgress(const FullMsgId &msgId);

View File

@ -6064,9 +6064,17 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const {
text = App::peerName(_authorOriginal);
}
if (via) {
text = lng_forwarded_via(lt_original, textcmdLink(1, text), lt_inline_bot, textcmdLink(2, '@' + via->_bot->username));
if (_authorOriginal->isChannel()) {
text = lng_forwarded_channel_via(lt_channel, textcmdLink(1, text), lt_inline_bot, textcmdLink(2, '@' + via->_bot->username));
} else {
text = lng_forwarded_via(lt_user, textcmdLink(1, text), lt_inline_bot, textcmdLink(2, '@' + via->_bot->username));
}
} else {
text = lng_forwarded(lt_original, textcmdLink(1, text));
if (_authorOriginal->isChannel()) {
text = lng_forwarded_channel(lt_channel, textcmdLink(1, text));
} else {
text = lng_forwarded(lt_user, textcmdLink(1, text));
}
}
TextParseOptions opts = { TextParseRichText, 0, 0, Qt::LayoutDirectionAuto };
textstyleSet(&st::inFwdTextStyle);

View File

@ -2607,6 +2607,40 @@ void CollapseButton::paintEvent(QPaintEvent *e) {
FlatButton::paintEvent(e);
}
SilentToggle::SilentToggle(QWidget *parent) : FlatCheckbox(parent, QString(), false, st::silentToggle) {
setMouseTracking(true);
}
void SilentToggle::mouseMoveEvent(QMouseEvent *e) {
FlatCheckbox::mouseMoveEvent(e);
if (rect().contains(e->pos())) {
PopupTooltip::Show(1000, this);
} else {
PopupTooltip::Hide();
}
}
void SilentToggle::leaveEvent(QEvent *e) {
PopupTooltip::Hide();
}
void SilentToggle::mouseReleaseEvent(QMouseEvent *e) {
FlatCheckbox::mouseReleaseEvent(e);
PopupTooltip::Show(0, this);
PeerData *p = App::main() ? App::main()->peer() : Nil;
if (p && p->isChannel() && p->notify != UnknownNotifySettings) {
App::main()->updateNotifySetting(p, NotifySettingDontChange, checked() ? SilentNotifiesSetSilent : SilentNotifiesSetNotify);
}
}
QString SilentToggle::tooltipText() const {
return lang(checked() ? lng_wont_be_notified : lng_will_be_notified);
}
QPoint SilentToggle::tooltipPos() const {
return QCursor::pos();
}
HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
, _replyToId(0)
, _replyToNameVersion(0)
@ -2659,6 +2693,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
, _kbHide(this, st::btnBotKbHide)
, _cmdStart(this, st::btnBotCmdStart)
, _broadcast(this, QString(), true, st::broadcastToggle)
, _silent(this)
, _cmdStartShown(false)
, _field(this, st::taMsgField, lang(lng_message_ph))
, _a_record(animation(this, &HistoryWidget::step_record))
@ -2667,8 +2702,11 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
, _inRecord(false)
, _inField(false)
, _inReplyEdit(false)
, a_recordingLevel(0, 0), _recordingSamples(0)
, a_recordOver(0, 0), a_recordDown(0, 0), a_recordCancel(st::recordCancel->c, st::recordCancel->c)
, a_recordingLevel(0, 0)
, _recordingSamples(0)
, a_recordOver(0, 0)
, a_recordDown(0, 0)
, a_recordCancel(st::recordCancel->c, st::recordCancel->c)
, _recordCancelWidth(st::recordFont->width(lang(lng_record_cancel)))
, _kbShown(false)
, _kbReplyTo(0)
@ -2708,7 +2746,8 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
connect(&_botStart, SIGNAL(clicked()), this, SLOT(onBotStart()));
connect(&_joinChannel, SIGNAL(clicked()), this, SLOT(onJoinChannel()));
connect(&_muteUnmute, SIGNAL(clicked()), this, SLOT(onMuteUnmute()));
connect(&_broadcast, SIGNAL(changed()), this, SLOT(onBroadcastChange()));
connect(&_broadcast, SIGNAL(changed()), this, SLOT(onBroadcastSilentChange()));
connect(&_silent, SIGNAL(clicked()), this, SLOT(onBroadcastSilentChange()));
connect(&_attachDocument, SIGNAL(clicked()), this, SLOT(onDocumentSelect()));
connect(&_attachPhoto, SIGNAL(clicked()), this, SLOT(onPhotoSelect()));
connect(&_field, SIGNAL(submitted(bool)), this, SLOT(onSend(bool)));
@ -2793,6 +2832,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
_kbShow.hide();
_kbHide.hide();
_broadcast.hide();
_silent.hide();
_cmdStart.hide();
_attachDocument.installEventFilter(&_attachType);
@ -3119,7 +3159,7 @@ void HistoryWidget::onRecordDone(QByteArray result, VoiceWaveform waveform, qint
App::wnd()->activateWindow();
int32 duration = samples / AudioVoiceMsgFrequency;
_fileLoader.addTask(new FileLoadTask(result, duration, waveform, FileLoadTo(_peer->id, _broadcast.checked(), replyToId())));
_fileLoader.addTask(new FileLoadTask(result, duration, waveform, FileLoadTo(_peer->id, _broadcast.checked(), _silent.checked(), replyToId())));
cancelReply(lastForceReplyReplied());
}
@ -3604,7 +3644,12 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
_history = App::history(_peer->id);
_migrated = _peer->migrateFrom() ? App::history(_peer->migrateFrom()->id) : 0;
if (_channel) updateNotifySettings();
if (_channel) {
updateNotifySettings();
if (_peer->notify == UnknownNotifySettings) {
App::wnd()->getNotifySetting(MTP_inputNotifyPeer(_peer->input));
}
}
if (_showAtMsgId == ShowAtUnreadMsgId) {
if (_history->lastWidth) {
@ -3702,6 +3747,12 @@ void HistoryWidget::updateNotifySettings() {
if (!_peer || !_peer->isChannel()) return;
_muteUnmute.setText(lang(_history->mute ? lng_channel_unmute : lng_channel_mute));
if (_peer->notify != UnknownNotifySettings) {
_silent.setChecked(_peer->notify != EmptyNotifySettings && (_peer->notify->flags & MTPDpeerNotifySettings::flag_silent));
if (_silent.isHidden() && hasSilentToggle()) {
updateControlsVisibility();
}
}
}
bool HistoryWidget::contentOverlapped(const QRect &globalRect) {
@ -3822,6 +3873,7 @@ void HistoryWidget::updateControlsVisibility() {
_attachPhoto.hide();
_attachEmoji.hide();
_broadcast.hide();
_silent.hide();
_toHistoryEnd.hide();
_collapseComments.hide();
_kbShow.hide();
@ -3873,6 +3925,7 @@ void HistoryWidget::updateControlsVisibility() {
_attachDocument.hide();
_attachPhoto.hide();
_broadcast.hide();
_silent.hide();
_kbScroll.hide();
_fieldBarCancel.hide();
_attachDocument.hide();
@ -3910,6 +3963,7 @@ void HistoryWidget::updateControlsVisibility() {
_attachDocument.hide();
_attachPhoto.hide();
_broadcast.hide();
_silent.hide();
_kbScroll.hide();
_fieldBarCancel.hide();
} else {
@ -3935,6 +3989,7 @@ void HistoryWidget::updateControlsVisibility() {
_attachDocument.hide();
_attachPhoto.hide();
_broadcast.hide();
_silent.hide();
if (_kbShown) {
_kbScroll.show();
} else {
@ -3982,6 +4037,11 @@ void HistoryWidget::updateControlsVisibility() {
} else {
_broadcast.hide();
}
if (hasSilentToggle()) {
_silent.show();
} else {
_silent.hide();
}
updateFieldPlaceholder();
}
if (_editMsgId || _replyToId || readyToForward() || (_previewData && _previewData->pendingTill >= 0) || _kbReplyTo) {
@ -4004,6 +4064,7 @@ void HistoryWidget::updateControlsVisibility() {
_attachDocument.hide();
_attachPhoto.hide();
_broadcast.hide();
_silent.hide();
_kbScroll.hide();
_fieldBarCancel.hide();
_attachDocument.hide();
@ -4576,7 +4637,7 @@ void HistoryWidget::onSend(bool ctrlShiftEnter, MsgId replyTo) {
WebPageId webPageId = _previewCancelled ? CancelledWebPageId : ((_previewData && _previewData->pendingTill >= 0) ? _previewData->id : 0);
App::main()->sendMessage(_history, _field.getLastText(), replyTo, _broadcast.checked(), webPageId);
App::main()->sendMessage(_history, _field.getLastText(), replyTo, _broadcast.checked(), _silent.checked(), webPageId);
setFieldText(QString());
_saveDraftText = true;
@ -4677,10 +4738,10 @@ bool HistoryWidget::joinFail(const RPCError &error, mtpRequestId req) {
}
void HistoryWidget::onMuteUnmute() {
App::main()->updateNotifySetting(_peer, _history->mute);
App::main()->updateNotifySetting(_peer, _history->mute ? NotifySettingSetNotify : NotifySettingSetMuted);
}
void HistoryWidget::onBroadcastChange() {
void HistoryWidget::onBroadcastSilentChange() {
updateFieldPlaceholder();
}
@ -4715,6 +4776,7 @@ void HistoryWidget::shareContact(const PeerId &peer, const QString &phone, const
bool channelPost = p->isChannel() && !p->isMegagroup() && p->asChannel()->canPublish() && (p->asChannel()->isBroadcast() || _broadcast.checked());
bool showFromName = !channelPost || p->asChannel()->addsSignature();
bool silentPost = channelPost && _silent.checked();
if (channelPost) {
sendFlags |= MTPmessages_SendMedia::flag_broadcast;
flags |= MTPDmessage::flag_views;
@ -4723,12 +4785,15 @@ void HistoryWidget::shareContact(const PeerId &peer, const QString &phone, const
if (showFromName) {
flags |= MTPDmessage::flag_from_id;
}
if (silentPost) {
sendFlags |= MTPmessages_SendMedia::flag_silent;
}
h->addNewMessage(MTP_message(MTP_int(flags), MTP_int(newId.msg), MTP_int(showFromName ? MTP::authedId() : 0), peerToMTP(peer), MTPnullFwdHeader, MTPint(), MTP_int(replyToId()), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaContact(MTP_string(phone), MTP_string(fname), MTP_string(lname), MTP_int(userId)), MTPnullMarkup, MTPnullEntities, MTP_int(1), MTPint()), NewMessageUnread);
h->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), p->input, MTP_int(replyTo), MTP_inputMediaContact(MTP_string(phone), MTP_string(fname), MTP_string(lname)), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, h->sendRequestId);
App::historyRegRandom(randomId, newId);
App::main()->finishForwarding(h, _broadcast.checked());
App::main()->finishForwarding(h, _broadcast.checked(), _silent.checked());
cancelReply(lastKeyboardUsed);
}
@ -4792,6 +4857,7 @@ void HistoryWidget::animShow(const QPixmap &bgAnimCache, const QPixmap &bgAnimTo
_attachEmoji.hide();
_attachMention.hide();
_broadcast.hide();
_silent.hide();
_kbShow.hide();
_kbHide.hide();
_cmdStart.hide();
@ -5062,7 +5128,7 @@ void HistoryWidget::sendBotCommand(const QString &cmd, MsgId replyTo) { // reply
toSend += '@' + username;
}
App::main()->sendMessage(_history, toSend, replyTo ? ((!_peer->isUser()/* && (botStatus == 0 || botStatus == 2)*/) ? replyTo : -1) : 0, false);
App::main()->sendMessage(_history, toSend, replyTo ? ((!_peer->isUser()/* && (botStatus == 0 || botStatus == 2)*/) ? replyTo : -1) : 0, false, false);
if (replyTo) {
cancelReply();
if (_keyboard.singleUse() && _keyboard.hasMarkup() && lastKeyboardUsed) {
@ -5211,6 +5277,10 @@ bool HistoryWidget::hasBroadcastToggle() const {
return _peer && _peer->isChannel() && !_peer->isMegagroup() && _peer->asChannel()->canPublish() && !_peer->asChannel()->isBroadcast();
}
bool HistoryWidget::hasSilentToggle() const {
return _peer && _peer->isChannel() && !_peer->isMegagroup() && _peer->asChannel()->canPublish() && _peer->notify != UnknownNotifySettings;
}
void HistoryWidget::inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result) {
_inlineBotResolveRequestId = 0;
// Notify::inlineBotRequesting(false);
@ -5569,6 +5639,7 @@ void HistoryWidget::onFieldResize() {
_kbShow.move(_attachEmoji.x() - _kbShow.width(), height() - kbh - _kbShow.height());
_kbHide.move(_attachEmoji.x(), _attachEmoji.y());
_cmdStart.move(_attachEmoji.x() - _cmdStart.width(), height() - kbh - _cmdStart.height());
_silent.move(_attachEmoji.x() - _silent.width(), height() - kbh - _silent.height());
_attachType.move(0, _attachDocument.y() - _attachType.height());
_emojiPan.moveBottom(_attachEmoji.y());
@ -5602,9 +5673,9 @@ void HistoryWidget::updateFieldPlaceholder() {
if (_inlineBot && _inlineBot != InlineBotLookingUpData) {
_field.setPlaceholder(_inlineBot->botInfo->inlinePlaceholder.mid(1), _inlineBot->username.size() + 2);
} else if (hasBroadcastToggle()) {
_field.setPlaceholder(lang(_broadcast.checked() ? lng_broadcast_ph : lng_comment_ph));
_field.setPlaceholder(lang(_broadcast.checked() ? (_silent.checked() ? lng_broadcast_silent_ph : lng_broadcast_ph) : lng_comment_ph));
} else {
_field.setPlaceholder(lang((_history && _history->isChannel() && !_history->isMegagroup()) ? (_peer->asChannel()->canPublish() ? lng_broadcast_ph : lng_comment_ph) : lng_message_ph));
_field.setPlaceholder(lang((_history && _history->isChannel() && !_history->isMegagroup()) ? (_peer->asChannel()->canPublish() ? (_silent.checked() ? lng_broadcast_silent_ph : lng_broadcast_ph) : lng_comment_ph) : lng_message_ph));
}
_send.setText(lang(lng_send_button));
}
@ -5614,7 +5685,7 @@ void HistoryWidget::uploadImage(const QImage &img, PrepareMediaType type, FileLo
if (!_history) return;
App::wnd()->activateWindow();
FileLoadTask *task = new FileLoadTask(img, type, FileLoadTo(_peer->id, _broadcast.checked(), replyToId()), confirm, source);
FileLoadTask *task = new FileLoadTask(img, type, FileLoadTo(_peer->id, _broadcast.checked(), _silent.checked(), replyToId()), confirm, source);
if (withText) {
_confirmWithTextId = task->fileid();
}
@ -5625,7 +5696,7 @@ void HistoryWidget::uploadFile(const QString &file, PrepareMediaType type, FileL
if (!_history) return;
App::wnd()->activateWindow();
FileLoadTask *task = new FileLoadTask(file, type, FileLoadTo(_peer->id, _broadcast.checked(), replyToId()), confirm);
FileLoadTask *task = new FileLoadTask(file, type, FileLoadTo(_peer->id, _broadcast.checked(), _silent.checked(), replyToId()), confirm);
if (withText) {
_confirmWithTextId = task->fileid();
}
@ -5639,7 +5710,7 @@ void HistoryWidget::uploadFiles(const QStringList &files, PrepareMediaType type)
App::wnd()->activateWindow();
FileLoadTo to(_peer->id, _broadcast.checked(), replyToId());
FileLoadTo to(_peer->id, _broadcast.checked(), _silent.checked(), replyToId());
TasksList tasks;
tasks.reserve(files.size());
@ -5655,7 +5726,7 @@ void HistoryWidget::uploadFileContent(const QByteArray &fileContent, PrepareMedi
if (!_history) return;
App::wnd()->activateWindow();
_fileLoader.addTask(new FileLoadTask(fileContent, type, FileLoadTo(_peer->id, _broadcast.checked(), replyToId())));
_fileLoader.addTask(new FileLoadTask(fileContent, type, FileLoadTo(_peer->id, _broadcast.checked(), _silent.checked(), replyToId())));
cancelReply(lastForceReplyReplied());
}
@ -5675,9 +5746,9 @@ void HistoryWidget::confirmSendFile(const FileLoadResultPtr &file, bool ctrlShif
FullMsgId newId(peerToChannel(file->to.peer), clientMsgId());
connect(App::uploader(), SIGNAL(photoReady(const FullMsgId&, const MTPInputFile&)), this, SLOT(onPhotoUploaded(const FullMsgId&, const MTPInputFile&)), Qt::UniqueConnection);
connect(App::uploader(), SIGNAL(documentReady(const FullMsgId&, const MTPInputFile&)), this, SLOT(onDocumentUploaded(const FullMsgId&, const MTPInputFile&)), Qt::UniqueConnection);
connect(App::uploader(), SIGNAL(thumbDocumentReady(const FullMsgId&, const MTPInputFile&, const MTPInputFile&)), this, SLOT(onThumbDocumentUploaded(const FullMsgId&, const MTPInputFile&, const MTPInputFile&)), Qt::UniqueConnection);
connect(App::uploader(), SIGNAL(photoReady(const FullMsgId&,bool,const MTPInputFile&)), this, SLOT(onPhotoUploaded(const FullMsgId&,bool,const MTPInputFile&)), Qt::UniqueConnection);
connect(App::uploader(), SIGNAL(documentReady(const FullMsgId&,bool,const MTPInputFile&)), this, SLOT(onDocumentUploaded(const FullMsgId&,bool,const MTPInputFile&)), Qt::UniqueConnection);
connect(App::uploader(), SIGNAL(thumbDocumentReady(const FullMsgId&,bool,const MTPInputFile&,const MTPInputFile&)), this, SLOT(onThumbDocumentUploaded(const FullMsgId&,bool,const MTPInputFile&, const MTPInputFile&)), Qt::UniqueConnection);
connect(App::uploader(), SIGNAL(photoProgress(const FullMsgId&)), this, SLOT(onPhotoProgress(const FullMsgId&)), Qt::UniqueConnection);
connect(App::uploader(), SIGNAL(documentProgress(const FullMsgId&)), this, SLOT(onDocumentProgress(const FullMsgId&)), Qt::UniqueConnection);
connect(App::uploader(), SIGNAL(photoFailed(const FullMsgId&)), this, SLOT(onPhotoFailed(const FullMsgId&)), Qt::UniqueConnection);
@ -5693,6 +5764,7 @@ void HistoryWidget::confirmSendFile(const FileLoadResultPtr &file, bool ctrlShif
if (file->to.replyTo) flags |= MTPDmessage::flag_reply_to_msg_id;
bool channelPost = h->peer->isChannel() && !h->peer->isMegagroup() && h->peer->asChannel()->canPublish() && (h->peer->asChannel()->isBroadcast() || file->to.broadcast);
bool showFromName = !channelPost || h->peer->asChannel()->addsSignature();
bool silentPost = channelPost && file->to.silent;
if (channelPost) {
flags |= MTPDmessage::flag_views;
flags |= MTPDmessage::flag_post;
@ -5700,6 +5772,9 @@ void HistoryWidget::confirmSendFile(const FileLoadResultPtr &file, bool ctrlShif
if (showFromName) {
flags |= MTPDmessage::flag_from_id;
}
if (silentPost) {
flags |= MTPDmessage::flag_silent;
}
if (file->type == PreparePhoto) {
h->addNewMessage(MTP_message(MTP_int(flags), MTP_int(newId.msg), MTP_int(showFromName ? MTP::authedId() : 0), peerToMTP(file->to.peer), MTPnullFwdHeader, MTPint(), MTP_int(file->to.replyTo), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaPhoto(file->photo, MTP_string(file->caption)), MTPnullMarkup, MTPnullEntities, MTP_int(1), MTPint()), NewMessageUnread);
} else if (file->type == PrepareDocument) {
@ -5746,7 +5821,7 @@ void HistoryWidget::cancelShareContact() {
}
}
void HistoryWidget::onPhotoUploaded(const FullMsgId &newId, const MTPInputFile &file) {
void HistoryWidget::onPhotoUploaded(const FullMsgId &newId, bool silent, const MTPInputFile &file) {
if (!MTP::authedId()) return;
HistoryItem *item = App::histItemById(newId);
if (item) {
@ -5760,9 +5835,13 @@ void HistoryWidget::onPhotoUploaded(const FullMsgId &newId, const MTPInputFile &
}
bool channelPost = hist->peer->isChannel() && !hist->peer->isMegagroup() && hist->peer->asChannel()->canPublish() && item->isPost();
bool silentPost = channelPost && silent;
if (channelPost) {
sendFlags |= MTPmessages_SendMedia::flag_broadcast;
}
if (silentPost) {
sendFlags |= MTPmessages_SendMedia::flag_silent;
}
QString caption = item->getMedia() ? item->getMedia()->getCaption() : QString();
hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), item->history()->peer->input, MTP_int(replyTo), MTP_inputMediaUploadedPhoto(file, MTP_string(caption)), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId);
}
@ -5792,7 +5871,7 @@ namespace {
}
}
void HistoryWidget::onDocumentUploaded(const FullMsgId &newId, const MTPInputFile &file) {
void HistoryWidget::onDocumentUploaded(const FullMsgId &newId, bool silent, const MTPInputFile &file) {
if (!MTP::authedId()) return;
HistoryMessage *item = dynamic_cast<HistoryMessage*>(App::histItemById(newId));
if (item) {
@ -5808,16 +5887,20 @@ void HistoryWidget::onDocumentUploaded(const FullMsgId &newId, const MTPInputFil
}
bool channelPost = hist->peer->isChannel() && !hist->peer->isMegagroup() && hist->peer->asChannel()->canPublish() && item->isPost();
bool silentPost = channelPost && silent;
if (channelPost) {
sendFlags |= MTPmessages_SendMedia::flag_broadcast;
}
if (silentPost) {
sendFlags |= MTPmessages_SendMedia::flag_silent;
}
QString caption = item->getMedia() ? item->getMedia()->getCaption() : QString();
hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), item->history()->peer->input, MTP_int(replyTo), MTP_inputMediaUploadedDocument(file, MTP_string(document->mime), _composeDocumentAttributes(document), MTP_string(caption)), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId);
}
}
}
void HistoryWidget::onThumbDocumentUploaded(const FullMsgId &newId, const MTPInputFile &file, const MTPInputFile &thumb) {
void HistoryWidget::onThumbDocumentUploaded(const FullMsgId &newId, bool silent, const MTPInputFile &file, const MTPInputFile &thumb) {
if (!MTP::authedId()) return;
HistoryMessage *item = dynamic_cast<HistoryMessage*>(App::histItemById(newId));
if (item) {
@ -5833,9 +5916,13 @@ void HistoryWidget::onThumbDocumentUploaded(const FullMsgId &newId, const MTPInp
}
bool channelPost = hist->peer->isChannel() && !hist->peer->isMegagroup() && hist->peer->asChannel()->canPublish() && item->isPost();
bool silentPost = channelPost && silent;
if (channelPost) {
sendFlags |= MTPmessages_SendMedia::flag_broadcast;
}
if (silentPost) {
sendFlags |= MTPmessages_SendMedia::flag_silent;
}
QString caption = item->getMedia() ? item->getMedia()->getCaption() : QString();
hist->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), item->history()->peer->input, MTP_int(replyTo), MTP_inputMediaUploadedThumbDocument(file, thumb, MTP_string(document->mime), _composeDocumentAttributes(document), MTP_string(caption)), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId);
}
@ -6047,7 +6134,7 @@ void HistoryWidget::resizeEvent(QResizeEvent *e) {
updateListSize(App::main() ? App::main()->contentScrollAddToY() : 0);
bool kbShowShown = _history && !_kbShown && _keyboard.hasMarkup();
_field.resize(width() - _send.width() - _attachDocument.width() - _attachEmoji.width() - (kbShowShown ? _kbShow.width() : 0) - (_cmdStartShown ? _cmdStart.width() : 0) - (hasBroadcastToggle() ? _broadcast.width() : 0), _field.height());
_field.resize(width() - _send.width() - _attachDocument.width() - _attachEmoji.width() - (kbShowShown ? _kbShow.width() : 0) - (_cmdStartShown ? _cmdStart.width() : 0) - (hasBroadcastToggle() ? _broadcast.width() : 0) - (hasSilentToggle() ? _silent.width() : 0), _field.height());
_toHistoryEnd.move((width() - _toHistoryEnd.width()) / 2, _scroll.y() + _scroll.height() - _toHistoryEnd.height() - st::historyToEndSkip);
updateCollapseCommentsVisibility();
@ -6062,6 +6149,7 @@ void HistoryWidget::resizeEvent(QResizeEvent *e) {
_kbShow.move(_attachEmoji.x() - _kbShow.width(), height() - kbh - _kbShow.height());
_kbHide.move(_attachEmoji.x(), _attachEmoji.y());
_cmdStart.move(_attachEmoji.x() - _cmdStart.width(), height() - kbh - _cmdStart.height());
_silent.move(_attachEmoji.x() - _silent.width(), height() - kbh - _silent.height());
_attachType.move(0, _attachDocument.y() - _attachType.height());
_emojiPan.moveBottom(_attachEmoji.y());
@ -6540,6 +6628,7 @@ void HistoryWidget::onInlineResultSend(InlineResult *result, UserData *bot) {
}
bool channelPost = _peer->isChannel() && !_peer->isMegagroup() && _peer->asChannel()->canPublish() && (_peer->asChannel()->isBroadcast() || _broadcast.checked());
bool showFromName = !channelPost || _peer->asChannel()->addsSignature();
bool silentPost = channelPost && _silent.checked();
if (channelPost) {
sendFlags |= MTPmessages_SendMedia::flag_broadcast;
flags |= MTPDmessage::flag_views;
@ -6548,6 +6637,9 @@ void HistoryWidget::onInlineResultSend(InlineResult *result, UserData *bot) {
if (showFromName) {
flags |= MTPDmessage::flag_from_id;
}
if (silentPost) {
sendFlags |= MTPmessages_SendMedia::flag_silent;
}
if (bot) {
flags |= MTPDmessage::flag_via_bot_id;
}
@ -6615,7 +6707,7 @@ void HistoryWidget::onInlineResultSend(InlineResult *result, UserData *bot) {
_history->addNewMessage(MTP_message(MTP_int(flags), MTP_int(newId.msg), MTP_int(showFromName ? MTP::authedId() : 0), peerToMTP(_history->peer->id), MTPnullFwdHeader, MTP_int(bot ? peerToUser(bot->id) : 0), MTP_int(replyToId()), MTP_int(unixtime()), MTP_string(result->message), MTP_messageMediaEmpty(), MTPnullMarkup, linksToMTP(result->entities), MTP_int(1), MTPint()), NewMessageUnread);
}
_history->sendRequestId = MTP::send(MTPmessages_SendInlineBotResult(MTP_int(sendFlags), _peer->input, MTP_int(replyToId()), MTP_long(randomId), MTP_long(result->queryId), MTP_string(result->id)), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, _history->sendRequestId);
App::main()->finishForwarding(_history, _broadcast.checked());
App::main()->finishForwarding(_history, _broadcast.checked(), _silent.checked());
cancelReply(lastKeyboardUsed);
App::historyRegRandom(randomId, newId);
@ -6662,16 +6754,24 @@ void HistoryWidget::sendExistingDocument(DocumentData *doc, const QString &capti
flags |= MTPDmessage::flag_reply_to_msg_id;
sendFlags |= MTPmessages_SendMedia::flag_reply_to_msg_id;
}
bool fromChannelName = _peer->isChannel() && !_peer->isMegagroup() && _peer->asChannel()->canPublish() && (_peer->asChannel()->isBroadcast() || _broadcast.checked());
if (fromChannelName) {
bool channelPost = _peer->isChannel() && !_peer->isMegagroup() && _peer->asChannel()->canPublish() && (_peer->asChannel()->isBroadcast() || _broadcast.checked());
bool showFromName = !channelPost || _peer->asChannel()->addsSignature();
bool silentPost = channelPost && _silent.checked();
if (channelPost) {
sendFlags |= MTPmessages_SendMedia::flag_broadcast;
} else {
flags |= MTPDmessage::flag_views;
flags |= MTPDmessage::flag_post;
}
if (showFromName) {
flags |= MTPDmessage::flag_from_id;
}
_history->addNewDocument(newId.msg, flags, 0, replyToId(), date(MTP_int(unixtime())), fromChannelName ? 0 : MTP::authedId(), doc, caption);
if (silentPost) {
sendFlags |= MTPmessages_SendMedia::flag_silent;
}
_history->addNewDocument(newId.msg, flags, 0, replyToId(), date(MTP_int(unixtime())), showFromName ? MTP::authedId() : 0, doc, caption);
_history->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), _peer->input, MTP_int(replyToId()), MTP_inputMediaDocument(MTP_inputDocument(MTP_long(doc->id), MTP_long(doc->access)), MTP_string(caption)), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, _history->sendRequestId);
App::main()->finishForwarding(_history, _broadcast.checked());
App::main()->finishForwarding(_history, _broadcast.checked(), _silent.checked());
cancelReply(lastKeyboardUsed);
if (doc->sticker()) App::main()->incrementSticker(doc);
@ -6710,16 +6810,24 @@ void HistoryWidget::sendExistingPhoto(PhotoData *photo, const QString &caption)
flags |= MTPDmessage::flag_reply_to_msg_id;
sendFlags |= MTPmessages_SendMedia::flag_reply_to_msg_id;
}
bool fromChannelName = _peer->isChannel() && !_peer->isMegagroup() && _peer->asChannel()->canPublish() && (_peer->asChannel()->isBroadcast() || _broadcast.checked());
if (fromChannelName) {
bool channelPost = _peer->isChannel() && !_peer->isMegagroup() && _peer->asChannel()->canPublish() && (_peer->asChannel()->isBroadcast() || _broadcast.checked());
bool showFromName = !channelPost || _peer->asChannel()->addsSignature();
bool silentPost = channelPost && _silent.checked();
if (channelPost) {
sendFlags |= MTPmessages_SendMedia::flag_broadcast;
} else {
flags |= MTPDmessage::flag_views;
flags |= MTPDmessage::flag_post;
}
if (showFromName) {
flags |= MTPDmessage::flag_from_id;
}
_history->addNewPhoto(newId.msg, flags, 0, replyToId(), date(MTP_int(unixtime())), fromChannelName ? 0 : MTP::authedId(), photo, caption);
if (silentPost) {
sendFlags |= MTPmessages_SendMedia::flag_silent;
}
_history->addNewPhoto(newId.msg, flags, 0, replyToId(), date(MTP_int(unixtime())), showFromName ? MTP::authedId() : 0, photo, caption);
_history->sendRequestId = MTP::send(MTPmessages_SendMedia(MTP_int(sendFlags), _peer->input, MTP_int(replyToId()), MTP_inputMediaPhoto(MTP_inputPhoto(MTP_long(photo->id), MTP_long(photo->access)), MTP_string(caption)), MTP_long(randomId), MTPnullMarkup), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::sendMessageFail), 0, 0, _history->sendRequestId);
App::main()->finishForwarding(_history, _broadcast.checked());
App::main()->finishForwarding(_history, _broadcast.checked(), _silent.checked());
cancelReply(lastKeyboardUsed);
App::historyRegRandom(randomId, newId);

View File

@ -391,6 +391,20 @@ public:
};
class SilentToggle : public FlatCheckbox, public AbstractTooltipShower {
public:
SilentToggle(QWidget *parent);
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void leaveEvent(QEvent *e);
// AbstractTooltipShower
virtual QString tooltipText() const;
virtual QPoint tooltipPos() const;
};
enum TextUpdateEventsFlags {
TextUpdateEventsSaveDraft = 0x01,
TextUpdateEventsSendTyping = 0x02,
@ -609,9 +623,9 @@ public slots:
void peerUpdated(PeerData *data);
void onFullPeerUpdated(PeerData *data);
void onPhotoUploaded(const FullMsgId &msgId, const MTPInputFile &file);
void onDocumentUploaded(const FullMsgId &msgId, const MTPInputFile &file);
void onThumbDocumentUploaded(const FullMsgId &msgId, const MTPInputFile &file, const MTPInputFile &thumb);
void onPhotoUploaded(const FullMsgId &msgId, bool silent, const MTPInputFile &file);
void onDocumentUploaded(const FullMsgId &msgId, bool silent, const MTPInputFile &file);
void onThumbDocumentUploaded(const FullMsgId &msgId, bool silent, const MTPInputFile &file, const MTPInputFile &thumb);
void onPhotoProgress(const FullMsgId &msgId);
void onDocumentProgress(const FullMsgId &msgId);
@ -633,7 +647,7 @@ public slots:
void onBotStart();
void onJoinChannel();
void onMuteUnmute();
void onBroadcastChange();
void onBroadcastSilentChange();
void onPhotoSelect();
void onDocumentSelect();
@ -770,6 +784,7 @@ private:
bool readyToForward() const;
bool hasBroadcastToggle() const;
bool hasSilentToggle() const;
PeerData *_peer, *_clearPeer; // cache _peer in _clearPeer when showing clear history box
ChannelId _channel;
@ -817,6 +832,7 @@ private:
EmojiButton _attachEmoji;
IconedButton _kbShow, _kbHide, _cmdStart;
FlatCheckbox _broadcast;
SilentToggle _silent;
bool _cmdStartShown;
MessageField _field;
Animation _a_record, _a_recording;

View File

@ -700,7 +700,11 @@ void LayoutOverviewVoice::getState(TextLinkPtr &link, HistoryCursorState &cursor
void LayoutOverviewVoice::updateName() const {
int32 version = 0;
if (const HistoryMessageForwarded *fwd = _parent->Get<HistoryMessageForwarded>()) {
_name.setText(st::semiboldFont, lng_forwarded(lt_original, App::peerName(_parent->fromOriginal())), _textNameOptions);
if (_parent->fromOriginal()->isChannel()) {
_name.setText(st::semiboldFont, lng_forwarded_channel(lt_channel, App::peerName(_parent->fromOriginal())), _textNameOptions);
} else {
_name.setText(st::semiboldFont, lng_forwarded(lt_user, App::peerName(_parent->fromOriginal())), _textNameOptions);
}
} else {
_name.setText(st::semiboldFont, App::peerName(_parent->from()), _textNameOptions);
}

View File

@ -166,10 +166,14 @@ private:
};
struct FileLoadTo {
FileLoadTo(const PeerId &peer, bool broadcast, MsgId replyTo) : peer(peer), broadcast(broadcast), replyTo(replyTo) {
FileLoadTo(const PeerId &peer, bool broadcast, bool silent, MsgId replyTo)
: peer(peer)
, broadcast(broadcast)
, silent(silent)
, replyTo(replyTo) {
}
PeerId peer;
bool broadcast;
bool broadcast, silent;
MsgId replyTo;
};

View File

@ -589,7 +589,7 @@ void MainWidget::cancelForwarding() {
history.cancelForwarding();
}
void MainWidget::finishForwarding(History *hist, bool broadcast) {
void MainWidget::finishForwarding(History *hist, bool broadcast, bool silent) {
if (!hist) return;
if (!_toForward.isEmpty()) {
@ -600,6 +600,7 @@ void MainWidget::finishForwarding(History *hist, bool broadcast) {
int32 sendFlags = 0, flags = 0;
bool channelPost = hist->peer->isChannel() && !hist->peer->isMegagroup() && hist->peer->asChannel()->canPublish() && (hist->peer->asChannel()->isBroadcast() || broadcast);
bool showFromName = !channelPost || hist->peer->asChannel()->addsSignature();
bool silentPost = channelPost && silent;
if (channelPost) {
sendFlags |= MTPmessages_ForwardMessages::flag_broadcast;
flags |= MTPDmessage::flag_views;
@ -608,6 +609,9 @@ void MainWidget::finishForwarding(History *hist, bool broadcast) {
if (showFromName) {
flags |= MTPDmessage::flag_from_id;
}
if (silentPost) {
sendFlags |= MTPmessages_ForwardMessages::flag_silent;
}
QVector<MTPint> ids;
QVector<MTPlong> randomIds;
@ -1267,7 +1271,7 @@ DialogsIndexed &MainWidget::dialogsList() {
return dialogs.dialogsList();
}
void MainWidget::sendMessage(History *hist, const QString &text, MsgId replyTo, bool broadcast, WebPageId webPageId) {
void MainWidget::sendMessage(History *hist, const QString &text, MsgId replyTo, bool broadcast, bool silent, WebPageId webPageId) {
readServerHistory(hist, false);
history.fastShowAtEnd(hist);
@ -1307,6 +1311,7 @@ void MainWidget::sendMessage(History *hist, const QString &text, MsgId replyTo,
}
bool channelPost = hist->peer->isChannel() && !hist->peer->isMegagroup() && hist->peer->asChannel()->canPublish() && (hist->peer->asChannel()->isBroadcast() || broadcast);
bool showFromName = !channelPost || hist->peer->asChannel()->addsSignature();
bool silentPost = channelPost && silent;
if (channelPost) {
sendFlags |= MTPmessages_SendMessage::flag_broadcast;
flags |= MTPDmessage::flag_views;
@ -1315,6 +1320,9 @@ void MainWidget::sendMessage(History *hist, const QString &text, MsgId replyTo,
if (showFromName) {
flags |= MTPDmessage::flag_from_id;
}
if (silentPost) {
sendFlags |= MTPmessages_SendMessage::flag_silent;
}
MTPVector<MTPMessageEntity> localEntities = linksToMTP(sendingEntities), sentEntities = linksToMTP(sendingEntities, true);
if (!sentEntities.c_vector().v.isEmpty()) {
sendFlags |= MTPmessages_SendMessage::flag_entities;
@ -1323,7 +1331,7 @@ void MainWidget::sendMessage(History *hist, const QString &text, MsgId replyTo,
hist->sendRequestId = MTP::send(MTPmessages_SendMessage(MTP_int(sendFlags), hist->peer->input, MTP_int(replyTo), msgText, MTP_long(randomId), MTPnullMarkup, sentEntities), rpcDone(&MainWidget::sentUpdatesReceived, randomId), rpcFail(&MainWidget::sendMessageFail), 0, 0, hist->sendRequestId);
}
finishForwarding(hist, broadcast);
finishForwarding(hist, broadcast, silent);
}
void MainWidget::saveRecentHashtags(const QString &text) {
@ -3719,28 +3727,37 @@ bool MainWidget::failNotifySetting(MTPInputNotifyPeer peer, const RPCError &erro
return true;
}
void MainWidget::updateNotifySetting(PeerData *peer, bool enabled) {
void MainWidget::updateNotifySetting(PeerData *peer, NotifySettingStatus notify, SilentNotifiesStatus silent) {
if (notify == NotifySettingDontChange && silent == SilentNotifiesDontChange) return;
updateNotifySettingPeers.insert(peer);
int32 muteFor = 86400 * 365;
if (peer->notify == EmptyNotifySettings) {
if (!enabled) {
peer->notify = new NotifySettings();
peer->notify->sound = "";
peer->notify->mute = unixtime() + muteFor;
}
} else {
if (peer->notify == UnknownNotifySettings) {
if (notify == NotifySettingSetMuted || silent == SilentNotifiesSetSilent) {
peer->notify = new NotifySettings();
}
peer->notify->sound = enabled ? "default" : "";
peer->notify->mute = enabled ? 0 : (unixtime() + muteFor);
} else if (peer->notify == UnknownNotifySettings) {
peer->notify = new NotifySettings();
}
if (!enabled) {
App::regMuted(peer, muteFor + 1);
} else {
App::unregMuted(peer);
if (peer->notify != EmptyNotifySettings && peer->notify != UnknownNotifySettings) {
if (notify != NotifySettingDontChange) {
peer->notify->sound = (notify == NotifySettingSetMuted) ? "" : "default";
peer->notify->mute = (notify == NotifySettingSetMuted) ? (unixtime() + muteFor) : 0;
}
if (silent == SilentNotifiesSetSilent) {
peer->notify->flags |= MTPDpeerNotifySettings::flag_silent;
} else if (silent == SilentNotifiesSetNotify) {
peer->notify->flags &= ~MTPDpeerNotifySettings::flag_silent;
}
}
if (notify != NotifySettingDontChange) {
if (notify == NotifySettingSetMuted) {
App::regMuted(peer, muteFor + 1);
} else {
App::unregMuted(peer);
}
App::history(peer->id)->setMute(notify == NotifySettingSetMuted);
}
App::history(peer->id)->setMute(!enabled);
if (history.peer() == peer) history.updateNotifySettings();
updateNotifySettingTimer.start(NotifySettingSaveTimeout);
}

View File

@ -183,6 +183,17 @@ inline int chatsListWidth(int windowWidth) {
return snap<int>((windowWidth * 5) / 14, st::dlgMinWidth, st::dlgMaxWidth);
}
enum SilentNotifiesStatus {
SilentNotifiesDontChange,
SilentNotifiesSetSilent,
SilentNotifiesSetNotify,
};
enum NotifySettingStatus {
NotifySettingDontChange,
NotifySettingSetMuted,
NotifySettingSetNotify,
};
class MainWidget : public TWidget, public RPCSender {
Q_OBJECT
@ -220,7 +231,7 @@ public:
void gotNotifySetting(MTPInputNotifyPeer peer, const MTPPeerNotifySettings &settings);
bool failNotifySetting(MTPInputNotifyPeer peer, const RPCError &error);
void updateNotifySetting(PeerData *peer, bool enabled);
void updateNotifySetting(PeerData *peer, NotifySettingStatus notify, SilentNotifiesStatus silent = SilentNotifiesDontChange);
void incrementSticker(DocumentData *sticker);
@ -320,7 +331,7 @@ public:
DialogsIndexed &contactsList();
DialogsIndexed &dialogsList();
void sendMessage(History *hist, const QString &text, MsgId replyTo, bool broadcast, WebPageId webPageId = 0);
void sendMessage(History *hist, const QString &text, MsgId replyTo, bool broadcast, bool silent, WebPageId webPageId = 0);
void saveRecentHashtags(const QString &text);
void readServerHistory(History *history, bool force = true);
@ -371,7 +382,7 @@ public:
void fillForwardingInfo(Text *&from, Text *&text, bool &serviceColor, ImagePtr &preview);
void updateForwardingTexts();
void cancelForwarding();
void finishForwarding(History *hist, bool broadcast); // send them
void finishForwarding(History *hist, bool broadcast, bool silent); // send them
void mediaMarkRead(DocumentData *data);
void mediaMarkRead(const HistoryItemsMap &items);

View File

@ -245,7 +245,7 @@ void ProfileInner::onSearchInPeer() {
}
void ProfileInner::onEnableNotifications() {
App::main()->updateNotifySetting(_peer, _enableNotifications.checked());
App::main()->updateNotifySetting(_peer, _enableNotifications.checked() ? NotifySettingSetNotify : NotifySettingSetMuted);
}
void ProfileInner::saveError(const QString &str) {