From fb539b0f70046e6fcf1f71212ef56cbfc8196348 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 27 Feb 2024 13:58:46 +0400 Subject: [PATCH] Improve shortcut messages geometry. --- Telegram/SourceFiles/history/history_item.cpp | 2 +- Telegram/SourceFiles/history/history_item_components.cpp | 6 ++++-- Telegram/SourceFiles/history/view/history_view_element.cpp | 2 +- .../settings/business/settings_shortcut_messages.cpp | 7 +++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 1f75a47d8..38f236c4b 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -735,7 +735,7 @@ TimeId HistoryItem::NewMessageDate(TimeId scheduled) { TimeId HistoryItem::NewMessageDate( const Api::SendOptions &options) { - return options.shortcutId ? TimeId() : NewMessageDate(options.scheduled); + return options.shortcutId ? 1 : NewMessageDate(options.scheduled); } HistoryServiceDependentData *HistoryItem::GetServiceDependentData() { diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index ee5d1d21f..f2ebc57c5 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwindow.h" #include "media/audio/media_audio.h" #include "media/player/media_player_instance.h" +#include "data/business/data_shortcut_messages.h" #include "data/stickers/data_custom_emoji.h" #include "data/data_channel.h" #include "data/data_media_types.h" @@ -301,10 +302,11 @@ ReplyFields ReplyFieldsFromMTP( if (const auto id = data.vreply_to_msg_id().value_or_empty()) { result.messageId = data.is_reply_to_scheduled() ? owner->scheduledMessages().localMessageId(id) - AssertIsDebug() + : item->shortcutId() + ? owner->shortcutMessages().localMessageId(id) : id; result.topMessageId - = data.vreply_to_top_id().value_or(id); + = data.vreply_to_top_id().value_or(result.messageId.bare); result.topicPost = data.is_forum_topic() ? 1 : 0; } if (const auto header = data.vreply_from()) { diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index bac85515a..3e142d0c9 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -462,7 +462,7 @@ Element::Element( Flag serviceFlag) : _delegate(delegate) , _data(data) -, _dateTime(IsItemScheduledUntilOnline(data) +, _dateTime((IsItemScheduledUntilOnline(data) || data->shortcutId()) ? QDateTime() : ItemDateTime(data)) , _text(st::msgMinWidth) diff --git a/Telegram/SourceFiles/settings/business/settings_shortcut_messages.cpp b/Telegram/SourceFiles/settings/business/settings_shortcut_messages.cpp index 8a1053da5..06ea5ac7e 100644 --- a/Telegram/SourceFiles/settings/business/settings_shortcut_messages.cpp +++ b/Telegram/SourceFiles/settings/business/settings_shortcut_messages.cpp @@ -337,8 +337,8 @@ ShortcutMessages::ShortcutMessages( _inner->setEmptyInfoWidget(std::move(emptyInfo)); } - widthValue() | rpl::start_with_next([=](int width) { - resize(width, width); + _inner->heightValue() | rpl::start_with_next([=](int height) { + resize(width(), height); }, lifetime()); } @@ -401,7 +401,6 @@ void ShortcutMessages::outerResized(QSize outer) { : 0; _skipScrollEvent = true; _inner->resizeToWidth(contentWidth, _scroll->height()); - resize(width(), _inner->height()); _skipScrollEvent = false; if (!_scroll->isHidden()) { @@ -743,7 +742,7 @@ void ShortcutMessages::listAddTranslatedItems( void ShortcutMessages::cornerButtonsShowAtPosition( Data::MessagePosition position) { - //showAtPosition(position); + showAtPosition(position); } Data::Thread *ShortcutMessages::cornerButtonsThread() {