From a586b18dfb308a4ef1ab24f3f5292240fb0cf2d5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 5 Jun 2020 13:03:45 +0400 Subject: [PATCH 1/8] Fix pending web pages applying. Fixes #7091. --- Telegram/SourceFiles/apiwrap.cpp | 62 +++------------------ Telegram/SourceFiles/data/data_web_page.cpp | 43 ++++++++++++++ Telegram/SourceFiles/data/data_web_page.h | 11 ++++ 3 files changed, 62 insertions(+), 54 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index b81d0e63f..24fb0ea18 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -2633,7 +2633,9 @@ void ApiWrap::resolveWebPages() { if (!ids.isEmpty()) { requestId = request(MTPmessages_GetMessages( MTP_vector(ids) - )).done([=](const MTPmessages_Messages &result, mtpRequestId requestId) { + )).done([=]( + const MTPmessages_Messages &result, + mtpRequestId requestId) { gotWebPages(nullptr, result, requestId); }).afterDelay(kSmallDelayMs).send(); } @@ -2642,7 +2644,9 @@ void ApiWrap::resolveWebPages() { reqsByIndex[i.value().first] = request(MTPchannels_GetMessages( i.key()->inputChannel, MTP_vector(i.value().second) - )).done([=, channel = i.key()](const MTPmessages_Messages &result, mtpRequestId requestId) { + )).done([=, channel = i.key()]( + const MTPmessages_Messages &result, + mtpRequestId requestId) { gotWebPages(channel, result, requestId); }).afterDelay(kSmallDelayMs).send(); } @@ -2957,58 +2961,8 @@ void ApiWrap::refreshFileReference( }); } -void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &msgs, mtpRequestId req) { - const QVector *v = 0; - switch (msgs.type()) { - case mtpc_messages_messages: { - auto &d = msgs.c_messages_messages(); - _session->data().processUsers(d.vusers()); - _session->data().processChats(d.vchats()); - v = &d.vmessages().v; - } break; - - case mtpc_messages_messagesSlice: { - auto &d = msgs.c_messages_messagesSlice(); - _session->data().processUsers(d.vusers()); - _session->data().processChats(d.vchats()); - v = &d.vmessages().v; - } break; - - case mtpc_messages_channelMessages: { - auto &d = msgs.c_messages_channelMessages(); - if (channel) { - channel->ptsReceived(d.vpts().v); - } else { - LOG(("API Error: received messages.channelMessages when no channel was passed! (ApiWrap::gotWebPages)")); - } - _session->data().processUsers(d.vusers()); - _session->data().processChats(d.vchats()); - v = &d.vmessages().v; - } break; - - case mtpc_messages_messagesNotModified: { - LOG(("API Error: received messages.messagesNotModified! (ApiWrap::gotWebPages)")); - } break; - } - - if (!v) return; - - auto indices = base::flat_map(); // copied from feedMsgs - for (auto i = 0, l = v->size(); i != l; ++i) { - const auto msgId = IdFromMessage(v->at(i)); - indices.emplace((uint64(uint32(msgId)) << 32) | uint64(i), i); - } - - for (const auto &[position, index] : indices) { - const auto item = _session->data().addNewMessage( - v->at(index), - MTPDmessage_ClientFlags(), - NewMessageType::Existing); - if (item) { - _session->data().requestItemResize(item); - } - } - +void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &result, mtpRequestId req) { + WebPageData::ApplyChanges(&session(), channel, result); for (auto i = _webPagesPending.begin(); i != _webPagesPending.cend();) { if (i.value() == req) { if (i.key()->pendingTill > 0) { diff --git a/Telegram/SourceFiles/data/data_web_page.cpp b/Telegram/SourceFiles/data/data_web_page.cpp index 4d0500ae2..d3a5eaa93 100644 --- a/Telegram/SourceFiles/data/data_web_page.cpp +++ b/Telegram/SourceFiles/data/data_web_page.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwidget.h" #include "data/data_session.h" #include "data/data_photo.h" +#include "data/data_channel.h" #include "data/data_document.h" #include "ui/image/image.h" #include "ui/text/text_entity.h" @@ -240,3 +241,45 @@ void WebPageData::replaceDocumentGoodThumbnail() { document->setGoodThumbnailPhoto(photo); } } + +void WebPageData::ApplyChanges( + not_null session, + ChannelData *channel, + const MTPmessages_Messages &result) { + result.match([&]( + const MTPDmessages_channelMessages &data) { + if (channel) { + channel->ptsReceived(data.vpts().v); + } else { + LOG(("API Error: received messages.channelMessages " + "when no channel was passed! (WebPageData::ApplyChanges)")); + } + }, [&](const auto &) { + }); + const auto list = result.match([]( + const MTPDmessages_messagesNotModified &) { + LOG(("API Error: received messages.messagesNotModified! " + "(WebPageData::ApplyChanges)")); + return static_cast*>(nullptr); + }, [&](const auto &data) { + session->data().processUsers(data.vusers()); + session->data().processChats(data.vchats()); + return &data.vmessages().v; + }); + if (!list) { + return; + } + + for (const auto &message : *list) { + message.match([&](const MTPDmessage &data) { + if (const auto media = data.vmedia()) { + media->match([&](const MTPDmessageMediaWebPage &data) { + session->data().processWebpage(data.vwebpage()); + }, [&](const auto &) { + }); + } + }, [&](const auto &) { + }); + } + session->data().sendWebPageGamePollNotifications(); +} \ No newline at end of file diff --git a/Telegram/SourceFiles/data/data_web_page.h b/Telegram/SourceFiles/data/data_web_page.h index f3e6dfbae..74e0aaae2 100644 --- a/Telegram/SourceFiles/data/data_web_page.h +++ b/Telegram/SourceFiles/data/data_web_page.h @@ -10,6 +10,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_photo.h" #include "data/data_document.h" +class ChannelData; + +namespace Main { +class Session; +} // namespace Main + enum class WebPageType { Photo, Video, @@ -50,6 +56,11 @@ struct WebPageData { const QString &newAuthor, int newPendingTill); + static void ApplyChanges( + not_null session, + ChannelData *channel, + const MTPmessages_Messages &result); + WebPageId id = 0; WebPageType type = WebPageType::Article; QString url; From 6c2a29b83f7fff06e8b0fab653b65e8d46fde2d0 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 5 Jun 2020 13:17:53 +0400 Subject: [PATCH 2/8] Fix possible crash in EditCaptionBox. --- Telegram/SourceFiles/boxes/edit_caption_box.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index 9b8c7411f..78057584c 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -192,7 +192,6 @@ EditCaptionBox::EditCaptionBox( maxH); _thumbnailImageLoaded = true; }; - prepareStreamedPreview(); } else { Assert(_photoMedia != nullptr); @@ -328,6 +327,10 @@ EditCaptionBox::EditCaptionBox( ) | rpl::start_with_next([&](bool checked) { _asFile = checked; }, _wayWrap->lifetime()); + + if (_animated) { + prepareStreamedPreview(); + } } EditCaptionBox::~EditCaptionBox() = default; From 05df4f832b335ca280a2b34180404d5104e6bc9e Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 5 Jun 2020 14:00:06 +0400 Subject: [PATCH 3/8] Fix crash in theme editor closing. --- .../SourceFiles/window/themes/window_theme_editor.cpp | 8 ++++---- Telegram/SourceFiles/window/themes/window_theme_editor.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp index 3530ee2ba..efeb5cf09 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp @@ -702,20 +702,20 @@ void Editor::showMenu() { if (_menu) { return; } - _menu.create(this); - _menu->setHiddenCallback([weak = Ui::MakeWeak(this), menu = _menu.data()]{ + _menu = base::make_unique_q(this); + _menu->setHiddenCallback([weak = Ui::MakeWeak(this), menu = _menu.get()]{ menu->deleteLater(); if (weak && weak->_menu == menu) { weak->_menu = nullptr; weak->_menuToggle->setForceRippled(false); } }); - _menu->setShowStartCallback(crl::guard(this, [this, menu = _menu.data()]{ + _menu->setShowStartCallback(crl::guard(this, [this, menu = _menu.get()]{ if (_menu == menu) { _menuToggle->setForceRippled(true); } })); - _menu->setHideStartCallback(crl::guard(this, [this, menu = _menu.data()]{ + _menu->setHideStartCallback(crl::guard(this, [this, menu = _menu.get()]{ if (_menu == menu) { _menuToggle->setForceRippled(false); } diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor.h b/Telegram/SourceFiles/window/themes/window_theme_editor.h index b8e459888..4daf7473b 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor.h +++ b/Telegram/SourceFiles/window/themes/window_theme_editor.h @@ -80,7 +80,7 @@ private: QPointer _inner; object_ptr _close; object_ptr _menuToggle; - object_ptr _menu = { nullptr }; + base::unique_qptr _menu; object_ptr _select; object_ptr _leftShadow; object_ptr _topShadow; From 06629ad171f7a4a1fd160cc6ba15452283996260 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 5 Jun 2020 14:26:42 +0400 Subject: [PATCH 4/8] Fix crash in PiP with bad video files. --- Telegram/SourceFiles/media/view/media_view_pip.cpp | 9 +++++++-- Telegram/SourceFiles/media/view/media_view_pip.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/media/view/media_view_pip.cpp b/Telegram/SourceFiles/media/view/media_view_pip.cpp index 4fb4baeb5..f026db604 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip.cpp +++ b/Telegram/SourceFiles/media/view/media_view_pip.cpp @@ -1152,7 +1152,7 @@ void Pip::paint(QPainter &p, FrameRequest request) { } else { p.drawImage(rect, RotateFrameImage(image, _rotation)); } - if (_instance.player().ready()) { + if (canUseVideoFrame()) { _instance.markFrameShown(); } paintRadialLoading(p); @@ -1377,8 +1377,13 @@ void Pip::restartAtSeekPosition(crl::time position) { updatePlaybackState(); } +bool Pip::canUseVideoFrame() const { + return _instance.player().ready() + && !_instance.info().video.cover.isNull(); +} + QImage Pip::videoFrame(const FrameRequest &request) const { - if (_instance.player().ready()) { + if (canUseVideoFrame()) { _preparedCoverStorage = QImage(); return _instance.frame(request); } diff --git a/Telegram/SourceFiles/media/view/media_view_pip.h b/Telegram/SourceFiles/media/view/media_view_pip.h index 6552b1bed..747139a48 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip.h +++ b/Telegram/SourceFiles/media/view/media_view_pip.h @@ -169,6 +169,7 @@ private: void updatePlayPauseResumeState(const Player::TrackState &state); void restartAtSeekPosition(crl::time position); + [[nodiscard]] bool canUseVideoFrame() const; [[nodiscard]] QImage videoFrame(const FrameRequest &request) const; [[nodiscard]] QImage videoFrameForDirectPaint( const FrameRequest &request) const; From 1c77b9c16fd24e573e5fec60bdf3c73b21ed0ec5 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 4 Jun 2020 00:16:07 +0300 Subject: [PATCH 5/8] Changed button names in SendFilesBox. Fixed #7988. --- Telegram/SourceFiles/boxes/send_files_box.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 268566f22..2f1df25c7 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -1831,11 +1831,7 @@ void SendFilesBox::setupShadows( } void SendFilesBox::prepare() { - _send = addButton( - (_sendType == Api::SendType::Normal - ? tr::lng_send_button() - : tr::lng_schedule_button()), - [=] { send({}); }); + _send = addButton(tr::lng_send_button(), [=] { send({}); }); if (_sendType == Api::SendType::Normal) { SetupSendMenuAndShortcuts( _send, @@ -1853,9 +1849,8 @@ void SendFilesBox::prepare() { } }, lifetime()); - const auto title = tr::lng_stickers_featured_add(tr::now) + qsl("..."); _addFileToAlbum = addLeftButton( - rpl::single(title), + tr::lng_stickers_featured_add(), App::LambdaDelayed(st::historyAttach.ripple.hideDuration, this, [=] { openDialogToAddFileToAlbum(); })); From f4042d5ad53523c1796e32a21bca4597238218be Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 4 Jun 2020 00:46:16 +0300 Subject: [PATCH 6/8] Fixed ability to see empty header in HistoryWidget. The problem occurs by pressing the left side of the header when there is no second layer. --- Telegram/SourceFiles/history/history_widget.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index e72ccd0f6..2574bfb69 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -5530,7 +5530,15 @@ void HistoryWidget::updateUnreadMentionsVisibility() { } void HistoryWidget::mousePressEvent(QMouseEvent *e) { - _replyForwardPressed = QRect(0, _field->y() - st::historySendPadding - st::historyReplyHeight, st::historyReplySkip, st::historyReplyHeight).contains(e->pos()); + const auto hasSecondLayer = (_editMsgId + || _replyToId + || readyToForward() + || _kbReplyTo); + _replyForwardPressed = hasSecondLayer && QRect( + 0, + _field->y() - st::historySendPadding - st::historyReplyHeight, + st::historyReplySkip, + st::historyReplyHeight).contains(e->pos()); if (_replyForwardPressed && !_fieldBarCancel->isHidden()) { updateField(); } else if (_inReplyEditForward) { From d4f2b8dd0e6ae30435aa58a3dc643c5ca9eabb29 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 4 Jun 2020 14:56:02 +0300 Subject: [PATCH 7/8] Fixed ability to edit media with sticker. Regression was introduced in efa4deef6a. --- Telegram/SourceFiles/storage/storage_media_prepare.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/storage/storage_media_prepare.cpp b/Telegram/SourceFiles/storage/storage_media_prepare.cpp index 9cd6a86e6..48ce0d75d 100644 --- a/Telegram/SourceFiles/storage/storage_media_prepare.cpp +++ b/Telegram/SourceFiles/storage/storage_media_prepare.cpp @@ -322,9 +322,6 @@ std::optional PreparedList::PreparedFileFromFilesDialog( auto filteredFiles = ranges::view::all( temp.files ) | ranges::view::filter([&](const auto &file) { - if (!isAlbum) { - return true; - } const auto info = QFileInfo(file.path); if (Core::IsMimeSticker(Core::MimeTypeForFile(info).name())) { if (isSingleFile) { @@ -332,6 +329,9 @@ std::optional PreparedList::PreparedFileFromFilesDialog( } return false; } + if (!isAlbum) { + return true; + } using Info = FileMediaInformation; const auto media = &file.information->media; From f50fdd0236369270becb68292076f67881b588ed Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 5 Jun 2020 20:04:22 +0400 Subject: [PATCH 8/8] Version 2.1.10. - Improve memory usage. - Add support for full group message history export. - Allow export of a single chat message history in JSON format. --- Telegram/Resources/uwp/AppX/AppxManifest.xml | 2 +- Telegram/Resources/winrc/Telegram.rc | 8 ++++---- Telegram/Resources/winrc/Updater.rc | 8 ++++---- Telegram/SourceFiles/core/version.h | 6 +++--- Telegram/build/version | 10 +++++----- Telegram/lib_ui | 2 +- changelog.txt | 6 ++++++ 7 files changed, 24 insertions(+), 18 deletions(-) diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index 1fee682e8..10caa4f8b 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -9,7 +9,7 @@ + Version="2.1.10.0" /> Telegram Desktop Telegram FZ-LLC diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 260dc4dc4..269096c02 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,1,9,0 - PRODUCTVERSION 2,1,9,0 + FILEVERSION 2,1,10,0 + PRODUCTVERSION 2,1,10,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -62,10 +62,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "2.1.9.0" + VALUE "FileVersion", "2.1.10.0" VALUE "LegalCopyright", "Copyright (C) 2014-2020" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "2.1.9.0" + VALUE "ProductVersion", "2.1.10.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index d3d05ef54..d371e8728 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,1,9,0 - PRODUCTVERSION 2,1,9,0 + FILEVERSION 2,1,10,0 + PRODUCTVERSION 2,1,10,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -53,10 +53,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop Updater" - VALUE "FileVersion", "2.1.9.0" + VALUE "FileVersion", "2.1.10.0" VALUE "LegalCopyright", "Copyright (C) 2014-2020" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "2.1.9.0" + VALUE "ProductVersion", "2.1.10.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index e66744ddd..00bf73d7d 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -22,7 +22,7 @@ constexpr auto AppId = "{53F49750-6209-4FBF-9CA8-7A333C87D1ED}"_cs; constexpr auto AppNameOld = "Telegram Win (Unofficial)"_cs; constexpr auto AppName = "Telegram Desktop"_cs; constexpr auto AppFile = "Telegram"_cs; -constexpr auto AppVersion = 2001009; -constexpr auto AppVersionStr = "2.1.9"; -constexpr auto AppBetaVersion = true; +constexpr auto AppVersion = 2001010; +constexpr auto AppVersionStr = "2.1.10"; +constexpr auto AppBetaVersion = false; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; diff --git a/Telegram/build/version b/Telegram/build/version index fa1ee7c9e..2e9acaed3 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,7 +1,7 @@ -AppVersion 2001009 +AppVersion 2001010 AppVersionStrMajor 2.1 -AppVersionStrSmall 2.1.9 -AppVersionStr 2.1.9 -BetaChannel 1 +AppVersionStrSmall 2.1.10 +AppVersionStr 2.1.10 +BetaChannel 0 AlphaVersion 0 -AppVersionOriginal 2.1.9.beta +AppVersionOriginal 2.1.10 diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 5429c4c53..05d1ee379 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 5429c4c53e646e2716a2fb9a6d1ac45d0e12b082 +Subproject commit 05d1ee3796b878f18af87b3684aef4ff142f9d5c diff --git a/changelog.txt b/changelog.txt index 1e73796bb..f02079cdb 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ +2.1.10 (05.06.20) + +- Improve memory usage. +- Add support for full group message history export. +- Allow export of a single chat message history in JSON format. + 2.1.9 beta (04.06.20) - Several crash fixes.