diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index f97b8f37e..f10ddf6a6 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -166,10 +166,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_pinned_quiz" = "Pinned quiz"; "lng_pinned_unpin_sure" = "Would you like to unpin this message?"; "lng_pinned_pin_sure" = "Would you like to pin this message?"; +"lng_pinned_pin_sure_group" = "Do you want to pin this message for all members in the group?"; "lng_pinned_pin_old_sure" = "Do you want to pin an older message while leaving a more recent one pinned?"; "lng_pinned_pin" = "Pin"; "lng_pinned_unpin" = "Unpin"; "lng_pinned_notify" = "Notify all members"; +"lng_pinned_also_for_other" = "Also pin for {user}"; "lng_pinned_messages_title#one" = "{count} pinned message"; "lng_pinned_messages_title#other" = "{count} pinned messages"; "lng_pinned_hide_all" = "Don't show pinned messages"; diff --git a/Telegram/SourceFiles/boxes/confirm_box.cpp b/Telegram/SourceFiles/boxes/confirm_box.cpp index b88270d91..d7c715eb8 100644 --- a/Telegram/SourceFiles/boxes/confirm_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_box.cpp @@ -464,6 +464,8 @@ PinMessageBox::PinMessageBox( this, (_pinningOld ? tr::lng_pinned_pin_old_sure(tr::now) + : (peer->isChat() || peer->isMegagroup()) + ? tr::lng_pinned_pin_sure_group(tr::now) : tr::lng_pinned_pin_sure(tr::now)), st::boxLabel) { } @@ -473,12 +475,27 @@ void PinMessageBox::prepare() { addButton(tr::lng_cancel(), [this] { closeBox(); }); if (!_pinningOld && (_peer->isChat() || _peer->isMegagroup())) { - _notify.create(this, tr::lng_pinned_notify(tr::now), true, st::defaultBoxCheckbox); + _notify.create( + this, + tr::lng_pinned_notify(tr::now), + true, + st::defaultBoxCheckbox); + _checkbox = _notify; + } else if (_peer->isUser() && !_peer->isSelf()) { + _pinForPeer.create( + this, + tr::lng_pinned_also_for_other( + tr::now, + lt_user, + _peer->shortName()), + true, + st::defaultBoxCheckbox); + _checkbox = _pinForPeer; } auto height = st::boxPadding.top() + _text->height() + st::boxPadding.bottom(); - if (_notify) { - height += st::boxMediumSkip + _notify->heightNoMargins(); + if (_checkbox) { + height += st::boxMediumSkip + _checkbox->heightNoMargins(); } setDimensions(st::boxWidth, height); } @@ -486,8 +503,8 @@ void PinMessageBox::prepare() { void PinMessageBox::resizeEvent(QResizeEvent *e) { BoxContent::resizeEvent(e); _text->moveToLeft(st::boxPadding.left(), st::boxPadding.top()); - if (_notify) { - _notify->moveToLeft(st::boxPadding.left(), _text->y() + _text->height() + st::boxMediumSkip); + if (_checkbox) { + _checkbox->moveToLeft(st::boxPadding.left(), _text->y() + _text->height() + st::boxMediumSkip); } } @@ -506,6 +523,9 @@ void PinMessageBox::pinMessage() { if (_notify && !_notify->checked()) { flags |= MTPmessages_UpdatePinnedMessage::Flag::f_silent; } + if (_pinForPeer && !_pinForPeer->checked()) { + flags |= MTPmessages_UpdatePinnedMessage::Flag::f_pm_oneside; + } _requestId = _api.request(MTPmessages_UpdatePinnedMessage( MTP_flags(flags), _peer->input, diff --git a/Telegram/SourceFiles/boxes/confirm_box.h b/Telegram/SourceFiles/boxes/confirm_box.h index 585d8ec52..dea112536 100644 --- a/Telegram/SourceFiles/boxes/confirm_box.h +++ b/Telegram/SourceFiles/boxes/confirm_box.h @@ -188,6 +188,8 @@ private: object_ptr _text; object_ptr _notify = { nullptr }; + object_ptr _pinForPeer = { nullptr }; + QPointer _checkbox; mtpRequestId _requestId = 0; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index a30aa9275..e1dce7896 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -537,6 +537,8 @@ void HistoryItem::setRealId(MsgId newId) { bool HistoryItem::canPin() const { if (id < 0 || !toHistoryMessage()) { return false; + } else if (const auto m = media(); m && m->call()) { + return false; } return _history->peer->canPinMessages(); }