From af0e87c56986e3eb4d3159ae01a39dfc85f20dad Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 07:09:18 +0400 Subject: [PATCH 01/15] Fix a crash on languages box open. --- Telegram/lib_ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 287af101d0208..dc8313f6ae6c8 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 287af101d02089cafeba588f75057414fd96f476 +Subproject commit dc8313f6ae6c87572512424818b9e24e7ef2383e From 04f040c9c55cd318b72deb0abac9cadae8e319ab Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 07:09:28 +0400 Subject: [PATCH 02/15] Fix a crash in emoji status set. --- Telegram/SourceFiles/ui/effects/emoji_fly_animation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/ui/effects/emoji_fly_animation.cpp b/Telegram/SourceFiles/ui/effects/emoji_fly_animation.cpp index 559e4ed356919..ef86379741697 100644 --- a/Telegram/SourceFiles/ui/effects/emoji_fly_animation.cpp +++ b/Telegram/SourceFiles/ui/effects/emoji_fly_animation.cpp @@ -65,7 +65,7 @@ EmojiFlyAnimation::EmojiFlyAnimation( QRect( rect.topLeft() + QPoint(skipx, skipy), QSize(_flySize, _flySize)), - _textColor(), + (_textColor ? _textColor() : st::infoPeerBadge.premiumFg->c), clip, crl::now()); if (_areaUpdated || _area.isEmpty()) { From 94ac9f93fad9c67a846a5ab298c6d3bd78352ff2 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 07:54:39 +0400 Subject: [PATCH 03/15] Don't shrink non-photo media. --- Telegram/SourceFiles/data/data_web_page.cpp | 3 +++ .../SourceFiles/history/view/media/history_view_web_page.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/data/data_web_page.cpp b/Telegram/SourceFiles/data/data_web_page.cpp index ec0f9645455e4..932e9e2341628 100644 --- a/Telegram/SourceFiles/data/data_web_page.cpp +++ b/Telegram/SourceFiles/data/data_web_page.cpp @@ -254,6 +254,9 @@ bool WebPageData::applyChanges( } return QString(); }(); + if (newDocument || !newCollage.items.empty() || !newPhoto) { + newHasLargeMedia = false; + } if (type == newType && url == resultUrl diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index f91e7ad553820..1c2cd2c82af3f 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -242,7 +242,7 @@ QSize WebPage::countOptimalSize() { using Flag = MediaWebPageFlag; if (_data->hasLargeMedia && (_flags & Flag::ForceLargeMedia)) { _asArticle = 0; - } else if (_data->photo && (_flags & Flag::ForceSmallMedia)) { + } else if (_data->hasLargeMedia && (_flags & Flag::ForceSmallMedia)) { _asArticle = 1; } else { _asArticle = _data->computeDefaultSmallMedia(); From eaf30d58be48fe7b7bd15a00faf2b9facc1969b9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 08:48:45 +0400 Subject: [PATCH 04/15] Open documents-in-web-previews in-app. --- .../history/view/media/history_view_web_page.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index 1c2cd2c82af3f..38b6dc2582710 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -801,7 +801,11 @@ ClickHandlerPtr WebPage::replaceAttachLink( if (!_attach->isReadyForOpen() || (_siteName.isEmpty() && _title.isEmpty() - && _description.isEmpty())) { + && _description.isEmpty()) + || (_data->document + && !_data->document->isWallPaper() + && !_data->document->isTheme()) + || !_data->collage.items.empty()) { return link; } return _openl; From e64a096dca74c0f3e55646f624bc083d2a83795c Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 08:51:42 +0400 Subject: [PATCH 05/15] Don't suggest shrinking media of direct photo links. --- Telegram/SourceFiles/data/data_web_page.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/data/data_web_page.cpp b/Telegram/SourceFiles/data/data_web_page.cpp index 932e9e2341628..e8eef897847be 100644 --- a/Telegram/SourceFiles/data/data_web_page.cpp +++ b/Telegram/SourceFiles/data/data_web_page.cpp @@ -254,7 +254,13 @@ bool WebPageData::applyChanges( } return QString(); }(); - if (newDocument || !newCollage.items.empty() || !newPhoto) { + const auto hasSiteName = !resultSiteName.isEmpty() ? 1 : 0; + const auto hasTitle = !resultTitle.isEmpty() ? 1 : 0; + const auto hasDescription = !newDescription.text.isEmpty() ? 1 : 0; + if (newDocument + || !newCollage.items.empty() + || !newPhoto + || (hasSiteName + hasTitle + hasDescription < 2)) { newHasLargeMedia = false; } From ec3fc8c749621cbbc626f34b84fded26dbb3c9d1 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 08:55:30 +0400 Subject: [PATCH 06/15] Send entities with customized webpage preview. Fixes #26981. --- Telegram/SourceFiles/apiwrap.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index b1fb115724386..1efb5a275e09f 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -3682,6 +3682,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) { Api::ConvertOption::SkipLocal); if (!sentEntities.v.isEmpty()) { sendFlags |= MTPmessages_SendMessage::Flag::f_entities; + mediaFlags |= MTPmessages_SendMedia::Flag::f_entities; } const auto clearCloudDraft = action.clearDraft; const auto topicRootId = action.replyTo.topicRootId; From 597816db09dd4e40e904e3403d91ea61e4e9273d Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 09:52:42 +0400 Subject: [PATCH 07/15] Show Saved Messages in Reply in another chat. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/boxes/peer_list_box.cpp | 23 +++++++++++-------- Telegram/SourceFiles/boxes/peer_list_box.h | 10 ++++---- .../boxes/peer_list_controllers.cpp | 8 +++++-- .../SourceFiles/boxes/peer_list_controllers.h | 4 +--- .../boxes/peers/choose_peer_box.cpp | 4 ++-- .../controls/history_view_draft_options.cpp | 6 ++--- 7 files changed, 31 insertions(+), 25 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 38fa3485593c8..c4603bca88d16 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2361,6 +2361,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_saved_messages" = "Saved Messages"; "lng_saved_short" = "Save"; "lng_saved_forward_here" = "Forward messages here for quick access"; +"lng_saved_quote_here" = "Quote here to save"; "lng_scheduled_messages" = "Scheduled Messages"; "lng_scheduled_messages_empty" = "No scheduled messages here yet..."; diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 28286f377127b..2c1e361fb11d8 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -456,7 +456,7 @@ int PeerListController::descriptionTopSkipMin() const { void PeerListBox::addSelectItem( not_null peer, anim::type animated) { - const auto respect = _controller->respectSavedMessagesChat(); + const auto respect = !_controller->savedMessagesChatStatus().isEmpty(); const auto text = (respect && peer->isSelf()) ? tr::lng_saved_short(tr::now) : (respect && peer->isRepliesChat()) @@ -579,8 +579,8 @@ void PeerListRow::refreshStatus() { _statusType = StatusType::LastSeen; _statusValidTill = 0; if (auto user = peer()->asUser()) { - if (_isSavedMessagesChat) { - setStatusText(tr::lng_saved_forward_here(tr::now)); + if (!_savedMessagesStatus.isEmpty()) { + setStatusText(_savedMessagesStatus); } else { auto time = base::unixtime::now(); setStatusText(Data::OnlineText(user, time)); @@ -613,7 +613,7 @@ void PeerListRow::refreshName(const style::PeerListItem &st) { if (!_initialized) { return; } - const auto text = _isSavedMessagesChat + const auto text = !_savedMessagesStatus.isEmpty() ? tr::lng_saved_messages(tr::now) : _isRepliesMessagesChat ? tr::lng_replies_messages(tr::now) @@ -683,7 +683,7 @@ QString PeerListRow::generateName() { } QString PeerListRow::generateShortName() { - return _isSavedMessagesChat + return !_savedMessagesStatus.isEmpty() ? tr::lng_saved_short(tr::now) : _isRepliesMessagesChat ? tr::lng_replies_messages(tr::now) @@ -699,7 +699,7 @@ Ui::PeerUserpicView &PeerListRow::ensureUserpicView() { PaintRoundImageCallback PeerListRow::generatePaintUserpicCallback( bool forceRound) { - const auto saved = _isSavedMessagesChat; + const auto saved = !_savedMessagesStatus.isEmpty(); const auto replies = _isRepliesMessagesChat; const auto peer = this->peer(); auto userpic = saved ? Ui::PeerUserpicView() : ensureUserpicView(); @@ -745,7 +745,9 @@ int PeerListRow::paintNameIconGetWidth( int availableWidth, int outerWidth, bool selected) { - if (special() || _isSavedMessagesChat || _isRepliesMessagesChat) { + if (special() + || !_savedMessagesStatus.isEmpty() + || _isRepliesMessagesChat) { return 0; } return _bagde.drawGetWidth( @@ -855,7 +857,7 @@ void PeerListRow::paintDisabledCheckUserpic( auto iconBorderPen = st.checkbox.check.border->p; iconBorderPen.setWidth(st.checkbox.selectWidth); - if (_isSavedMessagesChat) { + if (!_savedMessagesStatus.isEmpty()) { Ui::EmptyUserpic::PaintSavedMessages(p, userpicLeft, userpicTop, outerWidth, userpicRadius * 2); } else if (_isRepliesMessagesChat) { Ui::EmptyUserpic::PaintRepliesMessages(p, userpicLeft, userpicTop, outerWidth, userpicRadius * 2); @@ -1046,9 +1048,10 @@ void PeerListContent::setRowHidden(not_null row, bool hidden) { } void PeerListContent::addRowEntry(not_null row) { - if (_controller->respectSavedMessagesChat() && !row->special()) { + const auto savedMessagesStatus = _controller->savedMessagesChatStatus(); + if (!savedMessagesStatus.isEmpty() && !row->special()) { if (row->peer()->isSelf()) { - row->setIsSavedMessagesChat(true); + row->setSavedMessagesChatStatus(savedMessagesStatus); } else if (row->peer()->isRepliesChat()) { row->setIsRepliesMessagesChat(true); } diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index 837bb6e2c2512..6dfce4630ea2d 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -185,8 +185,8 @@ class PeerListRow { void setIsSearchResult(bool isSearchResult) { _isSearchResult = isSearchResult; } - void setIsSavedMessagesChat(bool isSavedMessagesChat) { - _isSavedMessagesChat = isSavedMessagesChat; + void setSavedMessagesChatStatus(QString savedMessagesStatus) { + _savedMessagesStatus = savedMessagesStatus; } void setIsRepliesMessagesChat(bool isRepliesMessagesChat) { _isRepliesMessagesChat = isRepliesMessagesChat; @@ -278,12 +278,12 @@ class PeerListRow { StatusType _statusType = StatusType::Online; crl::time _statusValidTill = 0; base::flat_set _nameFirstLetters; + QString _savedMessagesStatus; int _absoluteIndex = -1; State _disabledState = State::Active; bool _hidden : 1 = false; bool _initialized : 1 = false; bool _isSearchResult : 1 = false; - bool _isSavedMessagesChat : 1 = false; bool _isRepliesMessagesChat : 1 = false; }; @@ -517,8 +517,8 @@ class PeerListController : public PeerListSearchDelegate { void peerListSearchAddRow(PeerListRowId id) override; void peerListSearchRefreshRows() override; - [[nodiscard]] virtual bool respectSavedMessagesChat() const { - return false; + [[nodiscard]] virtual QString savedMessagesChatStatus() const { + return QString(); } [[nodiscard]] virtual int customRowHeight() { Unexpected("PeerListController::customRowHeight."); diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index 3e2c3abcdcb11..df1a24fba6755 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -313,7 +313,7 @@ void ChatsListBoxController::rebuildRows() { return count; }; auto added = 0; - if (respectSavedMessagesChat()) { + if (!savedMessagesChatStatus().isEmpty()) { if (appendRow(session().data().history(session().user()))) { ++added; } @@ -330,7 +330,7 @@ void ChatsListBoxController::rebuildRows() { const auto history = static_cast(a).history(); return history->inChatList(); }); - if (respectSavedMessagesChat()) { + if (!savedMessagesChatStatus().isEmpty()) { delegate()->peerListPartitionRows([](const PeerListRow &a) { return a.peer()->isSelf(); }); @@ -696,6 +696,10 @@ void ChooseRecipientBoxController::rowClicked(not_null row) { } } +QString ChooseRecipientBoxController::savedMessagesChatStatus() const { + return tr::lng_saved_forward_here(tr::now); +} + auto ChooseRecipientBoxController::createRow( not_null history) -> std::unique_ptr { const auto peer = history->peer; diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.h b/Telegram/SourceFiles/boxes/peer_list_controllers.h index 35b4e0f15ca0f..5d8ef334a2da1 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.h +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.h @@ -218,9 +218,7 @@ class ChooseRecipientBoxController Main::Session &session() const override; void rowClicked(not_null row) override; - bool respectSavedMessagesChat() const override { - return true; - } + QString savedMessagesChatStatus() const override; protected: void prepareViewHook() override; diff --git a/Telegram/SourceFiles/boxes/peers/choose_peer_box.cpp b/Telegram/SourceFiles/boxes/peers/choose_peer_box.cpp index 60031e0cef4e0..767b0c91511ed 100644 --- a/Telegram/SourceFiles/boxes/peers/choose_peer_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/choose_peer_box.cpp @@ -45,8 +45,8 @@ class ChoosePeerBoxController final Main::Session &session() const override; void rowClicked(not_null row) override; - bool respectSavedMessagesChat() const override { - return true; + QString savedMessagesChatStatus() const override { + return tr::lng_saved_forward_here(tr::now); } private: diff --git a/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp b/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp index ac6dd6fc33bd7..931aeef55793e 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp @@ -854,12 +854,12 @@ void ShowReplyToChatBox( ChooseRecipientBoxController::rowClicked(row); } - [[nodiscard]] rpl::producer singleChosen() const{ + [[nodiscard]] rpl::producer singleChosen() const { return _singleChosen.events(); } - bool respectSavedMessagesChat() const override { - return false; + QString savedMessagesChatStatus() const override { + return tr::lng_saved_quote_here(tr::now); } private: From 625ae87eea162e375303f319314fff65d65fb9f8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 10:12:48 +0400 Subject: [PATCH 08/15] Add "show-peer-id-below-about" option. --- .../SourceFiles/core/local_url_handlers.cpp | 15 +++++++++++++++ .../info/profile/info_profile_values.cpp | 19 +++++++++++++++++++ .../info/profile/info_profile_values.h | 2 ++ .../settings/settings_experimental.cpp | 2 ++ 4 files changed, 38 insertions(+) diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index e8121204da7bd..d029a9a780f34 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -644,6 +644,17 @@ bool OpenExternalLink( context); } +bool CopyPeerId( + Window::SessionController *controller, + const Match &match, + const QVariant &context) { + TextUtilities::SetClipboardText(TextForMimeData{ match->captured(1) }); + if (controller) { + controller->showToast(tr::lng_text_copied(tr::now)); + } + return true; +} + void ExportTestChatTheme( not_null controller, not_null theme) { @@ -985,6 +996,10 @@ const std::vector &InternalUrlHandlers() { u"^url:(.+)$"_q, OpenExternalLink }, + { + u"^copy:(.+)$"_q, + CopyPeerId + } }; return Result; } diff --git a/Telegram/SourceFiles/info/profile/info_profile_values.cpp b/Telegram/SourceFiles/info/profile/info_profile_values.cpp index 878366d155a11..198e739756b41 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_values.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_values.cpp @@ -7,6 +7,7 @@ For license and copyright information please follow this link: */ #include "info/profile/info_profile_values.h" +#include "base/options.h" #include "info/profile/info_profile_badge.h" #include "core/application.h" #include "core/click_handler_types.h" @@ -37,6 +38,12 @@ namespace { using UpdateFlag = Data::PeerUpdate::Flag; +base::options::toggle ShowPeerIdBelowAbout({ + .id = kOptionShowPeerIdBelowAbout, + .name = "Show Peer IDs in Profile", + .description = "Show peer IDs from API below their Bio / Description.", +}); + auto PlainAboutValue(not_null peer) { return peer->session().changes().peerFlagsValue( peer, @@ -87,6 +94,8 @@ void StripExternalLinks(TextWithEntities &text) { } // namespace +const char kOptionShowPeerIdBelowAbout[] = "show-peer-id-below-about"; + rpl::producer NameValue(not_null peer) { return peer->session().changes().peerFlagsValue( peer, @@ -209,6 +218,16 @@ TextWithEntities AboutWithEntities( if (stripExternal) { StripExternalLinks(result); } + if (ShowPeerIdBelowAbout.value()) { + using namespace Ui::Text; + if (!result.empty()) { + result.append("\n"); + } + result.append(Italic(u"id: "_q)); + const auto raw = peer->id.value & PeerId::kChatTypeMask; + const auto id = QString::number(raw); + result.append(Link(Italic(id), "internal:copy:" + id)); + } return result; } diff --git a/Telegram/SourceFiles/info/profile/info_profile_values.h b/Telegram/SourceFiles/info/profile/info_profile_values.h index b3a110fe41bec..67c9238fb24f2 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_values.h +++ b/Telegram/SourceFiles/info/profile/info_profile_values.h @@ -35,6 +35,8 @@ enum class SharedMediaType : signed char; namespace Info::Profile { +extern const char kOptionShowPeerIdBelowAbout[]; + inline auto ToSingleLine() { return rpl::map([](const QString &text) { return TextUtilities::SingleLine(text); diff --git a/Telegram/SourceFiles/settings/settings_experimental.cpp b/Telegram/SourceFiles/settings/settings_experimental.cpp index 97447adf132df..6104cabb1301a 100644 --- a/Telegram/SourceFiles/settings/settings_experimental.cpp +++ b/Telegram/SourceFiles/settings/settings_experimental.cpp @@ -19,6 +19,7 @@ For license and copyright information please follow this link: #include "core/launcher.h" #include "chat_helpers/tabbed_panel.h" #include "dialogs/dialogs_widget.h" +#include "info/profile/info_profile_values.h" #include "lang/lang_keys.h" #include "mainwindow.h" #include "media/player/media_player_instance.h" @@ -141,6 +142,7 @@ void SetupExperimental( addToggle(Dialogs::kOptionForumHideChatsList); addToggle(Core::kOptionFractionalScalingEnabled); addToggle(Window::kOptionViewProfileInChatsListContextMenu); + addToggle(Info::Profile::kOptionShowPeerIdBelowAbout); addToggle(Ui::GL::kOptionAllowLinuxNvidiaOpenGL); addToggle(Ui::kOptionUseSmallMsgBubbleRadius); addToggle(Media::Player::kOptionDisableAutoplayNext); From e2ea27cbef7026085495aa4cfe549f9eb4c8b43b Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 10:25:52 +0400 Subject: [PATCH 09/15] Fix select-by-words with link previews. --- .../history/view/history_view_message.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index d8bf40a552fb3..a5eebddfdb8e5 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -2802,7 +2802,11 @@ TextSelection Message::adjustSelection( const auto textSelection = mediaBefore ? media->skipSelection(selection) : selection; - auto textAdjusted = hasVisibleText() + const auto useSelection = [](TextSelection selection, bool skipped) { + return !skipped || (selection != TextSelection(uint16(), uint16())); + }; + auto textAdjusted = (hasVisibleText() + && useSelection(textSelection, mediaBefore)) ? text().adjustSelection(textSelection, type) : textSelection; auto textResult = mediaBefore @@ -2813,7 +2817,9 @@ TextSelection Message::adjustSelection( ? selection : skipTextSelection(selection); if (mediaDisplayed) { - auto mediaAdjusted = media->adjustSelection(mediaSelection, type); + auto mediaAdjusted = useSelection(mediaSelection, !mediaBefore) + ? media->adjustSelection(mediaSelection, type) + : mediaSelection; mediaResult = mediaBefore ? mediaAdjusted : unskipTextSelection(mediaAdjusted); @@ -2825,7 +2831,9 @@ TextSelection Message::adjustSelection( : mediaBefore ? skipTextSelection(textSelection) : media->skipSelection(mediaSelection); - auto entryAdjusted = entry->adjustSelection(entrySelection, type); + auto entryAdjusted = useSelection(entrySelection, true) + ? entry->adjustSelection(entrySelection, type) + : entrySelection; entryResult = unskipTextSelection(entryAdjusted); if (mediaDisplayed) { entryResult = media->unskipSelection(entryResult); From 478c6c4d366afc52e58e28214fd4ee2e40b0027a Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 10:57:07 +0400 Subject: [PATCH 10/15] Fix pending link previews in preview options box. --- Telegram/Resources/langs/lang.strings | 1 + .../controls/history_view_draft_options.cpp | 57 +++++++++++++------ .../history_view_webpage_processor.cpp | 6 +- .../controls/history_view_webpage_processor.h | 2 +- 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index c4603bca88d16..4244b1adffb78 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1166,6 +1166,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_mute_box_title" = "Mute notifications for..."; "lng_preview_loading" = "Getting Link Info..."; +"lng_preview_cant" = "Could not generate preview for this link."; "lng_profile_settings_section" = "Settings"; "lng_profile_bot_settings" = "Bot Settings"; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp b/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp index 931aeef55793e..ea09d9b14f807 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp @@ -7,6 +7,7 @@ For license and copyright information please follow this link: */ #include "history/view/controls/history_view_draft_options.h" +#include "base/timer_rpl.h" #include "base/unixtime.h" #include "boxes/peer_list_box.h" #include "boxes/peer_list_controllers.h" @@ -589,6 +590,9 @@ void DraftOptionsBox( QString link; Ui::SettingsSlider *tabs = nullptr; PreviewWrap *wrap = nullptr; + + Fn performSwitch; + Fn requestAndSwitch; rpl::lifetime resolveLifetime; }; const auto state = box->lifetime().make_state(); @@ -740,35 +744,54 @@ void DraftOptionsBox( }; const auto &resolver = args.resolver; - const auto performSwitch = [=](const QString &link, WebPageData *page) { - if (page) { + state->performSwitch = [=](const QString &link, WebPageData *page) { + const auto now = base::unixtime::now(); + if (!page || page->pendingTill > 0 && page->pendingTill < now) { + show->showToast(tr::lng_preview_cant(tr::now)); + } else if (page->pendingTill > 0) { + const auto delay = std::max(page->pendingTill - now, TimeId()); + base::timer_once( + (delay + 1) * crl::time(1000) + ) | rpl::start_with_next([=] { + state->requestAndSwitch(link, true); + }, state->resolveLifetime); + + page->owner().webPageUpdates( + ) | rpl::start_with_next([=](not_null updated) { + if (updated == page && !updated->pendingTill) { + state->resolveLifetime.destroy(); + state->performSwitch(link, page); + } + }, state->resolveLifetime); + } else { state->preview = page; state->webpage.id = page->id; state->webpage.url = page->url; state->webpage.manual = true; state->link = link; state->shown.force_assign(Section::Link); - } else { - show->showToast(u"Could not generate preview for this link."_q); } }; + state->requestAndSwitch = [=](const QString &link, bool force) { + resolver->request(link, force); + + state->resolveLifetime = resolver->resolved( + ) | rpl::start_with_next([=](const QString &resolved) { + if (resolved == link) { + state->resolveLifetime.destroy(); + state->performSwitch( + link, + resolver->lookup(link).value_or(nullptr)); + } + }); + }; const auto switchTo = [=](const QString &link) { if (link == state->link) { return; - } - if (const auto value = resolver->lookup(link)) { - performSwitch(link, *value); + } else if (const auto value = resolver->lookup(link)) { + state->performSwitch(link, *value); } else { - resolver->request(link); - state->resolveLifetime = resolver->resolved( - ) | rpl::start_with_next([=](const QString &resolved) { - if (resolved == link) { - state->resolveLifetime.destroy(); - performSwitch( - link, - resolver->lookup(link).value_or(nullptr)); - } - }); + state->requestAndSwitch(link, false); } }; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_webpage_processor.cpp b/Telegram/SourceFiles/history/view/controls/history_view_webpage_processor.cpp index 50abe57bd5135..ca5fb31c09a1f 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_webpage_processor.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_webpage_processor.cpp @@ -134,8 +134,8 @@ QString WebpageResolver::find(not_null page) const { return QString(); } -void WebpageResolver::request(const QString &link) { - if (_requestLink == link) { +void WebpageResolver::request(const QString &link, bool force) { + if (_requestLink == link && !force) { return; } const auto done = [=](const MTPDmessageMediaWebPage &data) { @@ -191,7 +191,7 @@ WebpageProcessor::WebpageProcessor( if (!ShowWebPagePreview(_data) || _link.isEmpty()) { return; } - _resolver->request(_link); + _resolver->request(_link, true); }) { _history->session().downloaderTaskFinished( ) | rpl::filter([=] { diff --git a/Telegram/SourceFiles/history/view/controls/history_view_webpage_processor.h b/Telegram/SourceFiles/history/view/controls/history_view_webpage_processor.h index f27d1ad6cd42d..5aac1fd6e9d24 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_webpage_processor.h +++ b/Telegram/SourceFiles/history/view/controls/history_view_webpage_processor.h @@ -62,7 +62,7 @@ class WebpageResolver final { [[nodiscard]] QString find(not_null page) const; - void request(const QString &link); + void request(const QString &link, bool force = false); void cancel(const QString &link); private: From 3b7448ccabdacabd351de35d7d28f4a722061a64 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 11:36:06 +0400 Subject: [PATCH 11/15] Version 4.12. - Fix crash in emoji status select. - Fix crash in language change. - Suggest shrinking only photos in webpage previews. - Fix opening video files in webpage previews in-app. - Fix sending links and markup with customized webpage previews. - Show "Saved Messages" as a first row when replying in another chat. - Fix selecting words by double-click with webpage previews. - Fix delayed webpage preview generation in preview options. - Add "show-peer-id-below-about" experimental option. --- Telegram/Resources/uwp/AppX/AppxManifest.xml | 2 +- Telegram/Resources/winrc/Telegram.rc | 8 ++++---- Telegram/Resources/winrc/Updater.rc | 8 ++++---- Telegram/SourceFiles/core/version.h | 4 ++-- Telegram/build/version | 10 +++++----- changelog.txt | 12 ++++++++++++ 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index 98297334155c9..ef4280feff3b1 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -10,7 +10,7 @@ + Version="4.12.0.0" /> Telegram Desktop Telegram Messenger LLP diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 2c2060f4a4550..69de28dc88bff 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 4,11,0,0 - PRODUCTVERSION 4,11,0,0 + FILEVERSION 4,12,0,0 + PRODUCTVERSION 4,12,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -62,10 +62,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "4.11.0.0" + VALUE "FileVersion", "4.12.0.0" VALUE "LegalCopyright", "Copyright (C) 2014-2023" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "4.11.0.0" + VALUE "ProductVersion", "4.12.0.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index d54e8a6d26695..2b17faabdf1ff 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 4,11,0,0 - PRODUCTVERSION 4,11,0,0 + FILEVERSION 4,12,0,0 + PRODUCTVERSION 4,12,0,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", "4.11.0.0" + VALUE "FileVersion", "4.12.0.0" VALUE "LegalCopyright", "Copyright (C) 2014-2023" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "4.11.0.0" + VALUE "ProductVersion", "4.12.0.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index 8fb21e740e86c..f47adfecc6553 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 = 4011000; -constexpr auto AppVersionStr = "4.11"; +constexpr auto AppVersion = 4012000; +constexpr auto AppVersionStr = "4.12"; constexpr auto AppBetaVersion = false; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; diff --git a/Telegram/build/version b/Telegram/build/version index 0e22fe75e1124..9eccfd6324bbf 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,7 +1,7 @@ -AppVersion 4011000 -AppVersionStrMajor 4.11 -AppVersionStrSmall 4.11 -AppVersionStr 4.11.0 +AppVersion 4012000 +AppVersionStrMajor 4.12 +AppVersionStrSmall 4.12 +AppVersionStr 4.12.0 BetaChannel 0 AlphaVersion 0 -AppVersionOriginal 4.11 +AppVersionOriginal 4.12 diff --git a/changelog.txt b/changelog.txt index dea2160da802c..2dc035e39a71f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,15 @@ +4.12 (29.10.23) + +- Fix crash in emoji status select. +- Fix crash in language change. +- Suggest shrinking only photos in webpage previews. +- Fix opening video files in webpage previews in-app. +- Fix sending links and markup with customized webpage previews. +- Show "Saved Messages" as a first row when replying in another chat. +- Fix selecting words by double-click with webpage previews. +- Fix delayed webpage preview generation in preview options. +- Add "show-peer-id-below-about" experimental option. + 4.11 (28.10.23) - View full statistics in your channels and group chats. From 096ddcad6d993814a07a8c1b7c485ec118add317 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 12:15:20 +0400 Subject: [PATCH 12/15] Version 4.11.1. - Fix crash in emoji status select. - Fix crash in language change. - Suggest shrinking only photos in webpage previews. - Fix opening video files in webpage previews in-app. - Fix sending links and markup with customized webpage previews. - Show "Saved Messages" as a first row when replying in another chat. - Fix selecting words by double-click with webpage previews. - Fix delayed webpage preview generation in preview options. - Add "show-peer-id-below-about" experimental option. --- Telegram/Resources/uwp/AppX/AppxManifest.xml | 2 +- Telegram/Resources/winrc/Telegram.rc | 8 ++++---- Telegram/Resources/winrc/Updater.rc | 8 ++++---- Telegram/SourceFiles/core/version.h | 4 ++-- .../view/controls/history_view_draft_options.cpp | 2 +- Telegram/build/version | 10 +++++----- changelog.txt | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index ef4280feff3b1..1422235cb3cb5 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -10,7 +10,7 @@ + Version="4.11.1.0" /> Telegram Desktop Telegram Messenger LLP diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 69de28dc88bff..5b638b6027513 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 4,12,0,0 - PRODUCTVERSION 4,12,0,0 + FILEVERSION 4,11,1,0 + PRODUCTVERSION 4,11,1,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -62,10 +62,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "4.12.0.0" + VALUE "FileVersion", "4.11.1.0" VALUE "LegalCopyright", "Copyright (C) 2014-2023" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "4.12.0.0" + VALUE "ProductVersion", "4.11.1.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index 2b17faabdf1ff..5903ca8d05f01 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 4,12,0,0 - PRODUCTVERSION 4,12,0,0 + FILEVERSION 4,11,1,0 + PRODUCTVERSION 4,11,1,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", "4.12.0.0" + VALUE "FileVersion", "4.11.1.0" VALUE "LegalCopyright", "Copyright (C) 2014-2023" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "4.12.0.0" + VALUE "ProductVersion", "4.11.1.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index f47adfecc6553..8bdb91ffdd12b 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 = 4012000; -constexpr auto AppVersionStr = "4.12"; +constexpr auto AppVersion = 4011001; +constexpr auto AppVersionStr = "4.11.1"; constexpr auto AppBetaVersion = false; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp b/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp index ea09d9b14f807..483a8d2800e81 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_draft_options.cpp @@ -746,7 +746,7 @@ void DraftOptionsBox( const auto &resolver = args.resolver; state->performSwitch = [=](const QString &link, WebPageData *page) { const auto now = base::unixtime::now(); - if (!page || page->pendingTill > 0 && page->pendingTill < now) { + if (!page || (page->pendingTill > 0 && page->pendingTill < now)) { show->showToast(tr::lng_preview_cant(tr::now)); } else if (page->pendingTill > 0) { const auto delay = std::max(page->pendingTill - now, TimeId()); diff --git a/Telegram/build/version b/Telegram/build/version index 9eccfd6324bbf..de406d1d20cb2 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,7 +1,7 @@ -AppVersion 4012000 -AppVersionStrMajor 4.12 -AppVersionStrSmall 4.12 -AppVersionStr 4.12.0 +AppVersion 4011001 +AppVersionStrMajor 4.11 +AppVersionStrSmall 4.11.1 +AppVersionStr 4.11.1 BetaChannel 0 AlphaVersion 0 -AppVersionOriginal 4.12 +AppVersionOriginal 4.11.1 diff --git a/changelog.txt b/changelog.txt index 2dc035e39a71f..c201151d7b274 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,4 @@ -4.12 (29.10.23) +4.11.1 (29.10.23) - Fix crash in emoji status select. - Fix crash in language change. From 5fee0a7a737610f28066893adab137c321d58cd2 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 12:31:45 +0400 Subject: [PATCH 13/15] Don't allow replying to local messages. --- Telegram/SourceFiles/history/history_inner_widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 2da2c97e41686..c4284cd8847fc 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2380,7 +2380,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { }; const auto addReplyAction = [&](HistoryItem *item) { - if (!item) { + if (!item || !item->isRegular()) { return; } const auto canSendReply = [&] { From 745ad45d47c2fb5c602ebc98ac1afbe789d2e4d9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 29 Oct 2023 12:31:10 +0400 Subject: [PATCH 14/15] Version 4.11.1: Update message text padding. --- Telegram/SourceFiles/ui/chat/chat.style | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index e0fe81fdcb206..0f1e19cde5b99 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -22,7 +22,7 @@ msgDateFont: font(13px); msgMinWidth: 160px; msgPhotoSize: 33px; msgPhotoSkip: 40px; -msgPadding: margins(10px, 8px, 10px, 8px); +msgPadding: margins(11px, 8px, 11px, 8px); msgMargin: margins(16px, 6px, 56px, 2px); msgMarginTopAttached: 0px; msgShadow: 2px; From f5c13fd9ccb2a7c672298a2b71e34661639390f8 Mon Sep 17 00:00:00 2001 From: xmdnx Date: Sun, 29 Oct 2023 17:38:53 +0000 Subject: [PATCH 15/15] version 4.11.1 --- Telegram/SourceFiles/rabbit/rabbit_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/rabbit/rabbit_version.h b/Telegram/SourceFiles/rabbit/rabbit_version.h index e21e0038a02b3..d0c092125bef4 100644 --- a/Telegram/SourceFiles/rabbit/rabbit_version.h +++ b/Telegram/SourceFiles/rabbit/rabbit_version.h @@ -7,6 +7,6 @@ For license and copyright information please follow this link: */ #pragma once -constexpr auto AppRabbitVersion = 4010004; -constexpr auto AppRabbitVersionStr = "4.10.4"; +constexpr auto AppRabbitVersion = 4011001; +constexpr auto AppRabbitVersionStr = "4.11.1"; constexpr auto AppRabbitBetaVersion = true; \ No newline at end of file