From 4b01043b27759333d53bb16ff3eec5d17d298c6e Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 1 Jun 2020 21:23:43 +0300 Subject: [PATCH] Added handling of deleting currently edited scheduled text messages. --- .../view/history_view_compose_controls.cpp | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp index 14cb51e580..e93dccb129 100644 --- a/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/history_view_compose_controls.cpp @@ -346,7 +346,7 @@ void ComposeControls::init() { }, _wrap->lifetime()); _header->editMsgId( - ) | rpl::start_with_next([=](auto id) { + ) | rpl::start_with_next([=](const auto &id) { updateHeight(); updateSendButtonType(); @@ -357,6 +357,24 @@ void ComposeControls::init() { _localSavedText = {}; } }, _wrap->lifetime()); + + { + const auto lastMsgId = _wrap->lifetime().make_state(); + + _header->editMsgId( + ) | rpl::filter([=](const auto &id) { + return !!id; + }) | rpl::start_with_next([=](const auto &id) { + *lastMsgId = id; + }, _wrap->lifetime()); + + _window->session().data().itemRemoved( + ) | rpl::filter([=](not_null item) { + return item->id && ((*lastMsgId) == item->fullId()); + }) | rpl::start_with_next([=] { + cancelEditMessage(); + }, _wrap->lifetime()); + } } void ComposeControls::setTextFromEditingMessage(not_null item) {