Fix auto-delete button when switching between chats.

This commit is contained in:
John Preston 2021-02-15 14:58:22 +04:00
parent 4896509ddf
commit 5b6503bfed
3 changed files with 8 additions and 2 deletions

View file

@ -5417,7 +5417,7 @@ void HistoryWidget::checkMessagesTTL() {
updateControlsGeometry(); updateControlsGeometry();
updateControlsVisibility(); updateControlsVisibility();
} }
} else if (!_ttlInfo) { } else if (!_ttlInfo || _ttlInfo->peer() != _peer) {
_ttlInfo = std::make_unique<HistoryView::Controls::TTLButton>( _ttlInfo = std::make_unique<HistoryView::Controls::TTLButton>(
this, this,
_peer); _peer);

View file

@ -92,7 +92,8 @@ void AutoDeleteSettingsBox(
} }
TTLButton::TTLButton(not_null<QWidget*> parent, not_null<PeerData*> peer) TTLButton::TTLButton(not_null<QWidget*> parent, not_null<PeerData*> peer)
: _button(parent, st::historyMessagesTTL) { : _peer(peer)
, _button(parent, st::historyMessagesTTL) {
_button.setClickedCallback([=] { _button.setClickedCallback([=] {
const auto canEdit = peer->isUser() const auto canEdit = peer->isUser()
|| (peer->isChat() || (peer->isChat()

View file

@ -23,6 +23,10 @@ class TTLButton final {
public: public:
TTLButton(not_null<QWidget*> parent, not_null<PeerData*> peer); TTLButton(not_null<QWidget*> parent, not_null<PeerData*> peer);
[[nodiscard]] not_null<PeerData*> peer() const {
return _peer;
}
void show(); void show();
void hide(); void hide();
void move(int x, int y); void move(int x, int y);
@ -30,6 +34,7 @@ public:
[[nodiscard]] int width() const; [[nodiscard]] int width() const;
private: private:
const not_null<PeerData*> _peer;
Ui::IconButton _button; Ui::IconButton _button;
}; };