2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Extend pinned messages support.

Support them in saved messages and normal groups.
This commit is contained in:
John Preston
2018-10-31 15:29:14 +04:00
parent 6d65cf2382
commit 78da810114
12 changed files with 122 additions and 99 deletions

View File

@@ -403,8 +403,11 @@ void ConvertToSupergroupBox::paintEvent(QPaintEvent *e) {
_note.drawLeft(p, st::boxPadding.left(), _textHeight + st::boxPadding.bottom(), _textWidth, width());
}
PinMessageBox::PinMessageBox(QWidget*, ChannelData *channel, MsgId msgId)
: _channel(channel)
PinMessageBox::PinMessageBox(
QWidget*,
not_null<PeerData*> peer,
MsgId msgId)
: _peer(peer)
, _msgId(msgId)
, _text(this, lang(lng_pinned_pin_sure), Ui::FlatLabel::InitType::Simple, st::boxLabel) {
}
@@ -413,7 +416,7 @@ void PinMessageBox::prepare() {
addButton(langFactory(lng_pinned_pin), [this] { pinMessage(); });
addButton(langFactory(lng_cancel), [this] { closeBox(); });
if (_channel->isMegagroup()) {
if (_peer->isChat() || _peer->isMegagroup()) {
_notify.create(this, lang(lng_pinned_notify), true, st::defaultBoxCheckbox);
}
@@ -443,14 +446,14 @@ void PinMessageBox::keyPressEvent(QKeyEvent *e) {
void PinMessageBox::pinMessage() {
if (_requestId) return;
auto flags = MTPchannels_UpdatePinnedMessage::Flags(0);
auto flags = MTPmessages_UpdatePinnedMessage::Flags(0);
if (_notify && !_notify->checked()) {
flags |= MTPchannels_UpdatePinnedMessage::Flag::f_silent;
flags |= MTPmessages_UpdatePinnedMessage::Flag::f_silent;
}
_requestId = MTP::send(
MTPchannels_UpdatePinnedMessage(
MTPmessages_UpdatePinnedMessage(
MTP_flags(flags),
_channel->inputChannel,
_peer->input,
MTP_int(_msgId)),
rpcDone(&PinMessageBox::pinDone),
rpcFail(&PinMessageBox::pinFail));

View File

@@ -142,7 +142,7 @@ private:
class PinMessageBox : public BoxContent, public RPCSender {
public:
PinMessageBox(QWidget*, ChannelData *channel, MsgId msgId);
PinMessageBox(QWidget*, not_null<PeerData*> peer, MsgId msgId);
protected:
void prepare() override;
@@ -155,7 +155,7 @@ private:
void pinDone(const MTPUpdates &updates);
bool pinFail(const RPCError &error);
ChannelData *_channel;
not_null<PeerData*> _peer;
MsgId _msgId;
object_ptr<Ui::FlatLabel> _text;