Attempt to fix topic draft saving.

This commit is contained in:
John Preston
2025-12-19 16:55:59 +04:00
parent b04866a2fc
commit a103047e03
3 changed files with 16 additions and 11 deletions

View File

@@ -463,9 +463,6 @@ ChatWidget::ChatWidget(
ChatWidget::~ChatWidget() {
base::take(_sendAction);
if (_repliesRootId || _sublist) {
session().api().saveCurrentDraftToCloud();
}
if (_repliesRootId) {
controller()->sendingAnimation().clear();
}

View File

@@ -429,7 +429,11 @@ MainWidget::MainWidget(
session().data().stickers().notifySavedGifsUpdated();
}
MainWidget::~MainWidget() = default;
MainWidget::~MainWidget() {
if (_controller->activeChatCurrent()) {
session().api().saveCurrentDraftToCloud();
}
}
Main::Session &MainWidget::session() const {
return _controller->session();

View File

@@ -2110,17 +2110,21 @@ void SessionController::setActiveChatEntry(Dialogs::RowDescriptor row) {
if (windowId().type == SeparateType::SharedMedia) {
return;
}
const auto was = _activeChatEntry.current().key.history();
const auto now = row.key.history();
if (was && was != now) {
const auto was = _activeChatEntry.current();
if (was.key && was.key != row.key) {
session().api().saveCurrentDraftToCloud();
}
const auto wasHistory = was.key.history();
const auto nowHistory = row.key.history();
if (wasHistory && wasHistory != nowHistory) {
_activeHistoryLifetime.destroy();
was->setFakeUnreadWhileOpened(false);
wasHistory->setFakeUnreadWhileOpened(false);
_invitePeekTimer.cancel();
}
_activeChatEntry = row;
if (now) {
now->setFakeUnreadWhileOpened(true);
if (const auto channel = now->peer->asChannel()
if (nowHistory) {
nowHistory->setFakeUnreadWhileOpened(true);
if (const auto channel = nowHistory->peer->asChannel()
; channel && !channel->isForum()) {
Data::PeerFlagValue(
channel,