diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 69268f05e215a..1a302bd10cd33 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -1731,7 +1731,9 @@ std::unique_ptr HistoryInner::prepareDrag() { updateDragSelection(nullptr, nullptr, false); _selectScroll.cancel(); - if (!urls.isEmpty()) mimeData->setUrls(urls); + if (!urls.isEmpty()) { + mimeData->setUrls(urls); + } if (uponSelected && !_controller->adaptive().isOneColumn()) { auto selectedState = getSelectionState(); if (selectedState.count > 0 && selectedState.count == selectedState.canForwardCount) { @@ -1752,21 +1754,21 @@ std::unique_ptr HistoryInner::prepareDrag() { == forwardSelectionState.canForwardCount)) { forwardIds = getSelectedItems(); } else if (_mouseCursorState == CursorState::Date) { - forwardIds = session().data().itemOrItsGroup(_mouseActionItem); + const auto item = _mouseActionItem; + if (item && item->allowsForward()) { + forwardIds = session().data().itemOrItsGroup(item); + } } else if ((pressedView->isHiddenByGroup() && pressedHandler) || (pressedView->media() && pressedView->media()->dragItemByHandler(pressedHandler))) { const auto item = _dragStateItem ? _dragStateItem : _mouseActionItem; - forwardIds = MessageIdsList(1, item->fullId()); - } - if (forwardIds.empty()) { - return nullptr; + if (item && item->allowsForward()) { + forwardIds = MessageIdsList(1, item->fullId()); + } } - session().data().setMimeForwardIds(std::move(forwardIds)); - auto result = std::make_unique(); - result->setData(u"application/x-td-forward"_q, "1"); + if (pressedHandler) { const auto lnkDocument = reinterpret_cast( pressedHandler->property( @@ -1774,12 +1776,23 @@ std::unique_ptr HistoryInner::prepareDrag() { if (lnkDocument) { const auto filepath = lnkDocument->filepath(true); if (!filepath.isEmpty()) { - QList urls; urls.push_back(QUrl::fromLocalFile(filepath)); - result->setUrls(urls); } } } + + if (forwardIds.empty() && urls.isEmpty()) { + return nullptr; + } + + auto result = std::make_unique(); + if (!forwardIds.empty()) { + session().data().setMimeForwardIds(std::move(forwardIds)); + result->setData(u"application/x-td-forward"_q, "1"); + } + if (!urls.isEmpty()) { + result->setUrls(urls); + } return result; } return nullptr; diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 2c99c6343a5e7..4155adf9b8c65 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -3778,12 +3778,7 @@ std::unique_ptr ListWidget::prepareDrag() { forwardIds = MessageIdsList(1, exactItem->fullId()); } } - if (forwardIds.empty()) { - return nullptr; - } - session().data().setMimeForwardIds(std::move(forwardIds)); - auto result = std::make_unique(); - result->setData(u"application/x-td-forward"_q, "1"); + if (pressedHandler) { const auto lnkDocument = reinterpret_cast( pressedHandler->property( @@ -3791,12 +3786,23 @@ std::unique_ptr ListWidget::prepareDrag() { if (lnkDocument) { const auto filepath = lnkDocument->filepath(true); if (!filepath.isEmpty()) { - QList urls; urls.push_back(QUrl::fromLocalFile(filepath)); - result->setUrls(urls); } } } + + if (forwardIds.empty() && urls.isEmpty()) { + return nullptr; + } + + auto result = std::make_unique(); + if (!forwardIds.empty()) { + session().data().setMimeForwardIds(std::move(forwardIds)); + result->setData(u"application/x-td-forward"_q, "1"); + } + if (!urls.isEmpty()) { + result->setUrls(urls); + } return result; } return nullptr;