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();
updateControlsVisibility();
}
} else if (!_ttlInfo) {
} else if (!_ttlInfo || _ttlInfo->peer() != _peer) {
_ttlInfo = std::make_unique<HistoryView::Controls::TTLButton>(
this,
_peer);

View File

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

View File

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