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/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/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; 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(); })); diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index 6c0a3f08f..80ab34408 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -23,7 +23,7 @@ constexpr auto AppId = "{C4A4AE8F-B9F7-4CC7-8A6C-BF7EEE87ACA5}"_cs; constexpr auto AppNameOld = "Telegram Win (Unofficial)"_cs; constexpr auto AppName = "Kotatogram Desktop"_cs; constexpr auto AppFile = "Kotatogram"_cs; -constexpr auto AppVersion = 2001009; -constexpr auto AppVersionStr = "2.1.9"; +constexpr auto AppVersion = 2001010; +constexpr auto AppVersionStr = "2.1.10"; constexpr auto AppBetaVersion = true; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; 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; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 3bf1775a0..c042f2ed7 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -5626,7 +5626,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) { 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; 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; diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp index 0f006783b..386286890 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; 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/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.