diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 7882698284..765aaf2f14 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -1561,6 +1561,19 @@ void History::addItemToBlock(not_null item) { const auto view = block->messages.back().get(); view->attachToBlock(block, block->messages.size() - 1); + if (item->Has()) { + if (const auto prev = view->previousInBlocks()) { + if (const auto nfr = prev->data()->Get()) { + if (!nfr->actionTaken) { + nfr->actionTaken = true; + if (nfr->expired) { + owner().requestItemViewRefresh(prev->data()); + } + } + } + } + } + if (isBuildingFrontBlock() && _buildingFrontBlock->expectedItemsCount > 0) { --_buildingFrontBlock->expectedItemsCount; } @@ -2574,6 +2587,18 @@ void History::finishBuildingFrontBlock() { // we've added a new front block, so previous item for // the old first item of a first block was changed first->previousInBlocksChanged(); + + if (first->data()->Has()) { + const auto last = block->messages.back()->data(); + if (const auto nfr = last->Get()) { + if (!nfr->actionTaken) { + nfr->actionTaken = true; + if (nfr->expired) { + owner().requestItemViewRefresh(last); + } + } + } + } } else { block->messages.back()->nextInBlocksRemoved(); } diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index a09b0e680e..7f1a171473 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -2162,6 +2162,8 @@ void HistoryItem::setStoryFields(not_null story) { } void HistoryItem::applyEdition(const MTPDmessageService &message) { + const auto wasNfr = Get(); + const auto wasActionTaken = wasNfr && wasNfr->actionTaken; const auto wasSublist = savedSublist(); if (message.vaction().type() == mtpc_messageActionHistoryClear) { const auto wasGrouped = history()->owner().groups().isGrouped(this); @@ -2218,6 +2220,9 @@ void HistoryItem::applyEdition(const MTPDmessageService &message) { updateReactions(message.vreactions()); } + if (const auto nowNfr = Get()) { + nowNfr->actionTaken = wasActionTaken; + } const auto nowSublist = savedSublist(); if (wasSublist && nowSublist != wasSublist) { wasSublist->removeOne(this); @@ -4947,6 +4952,8 @@ void HistoryItem::createServiceFromMtp(const MTPDmessageService &message) { ? SuggestRefundType::Expired : SuggestRefundType::User; finish->price = CreditsAmountFromTL(data.vprice()); + } else if (type == mtpc_messageActionNoForwardsToggle) { + AddComponents(HistoryServiceNoForwardsToggle::Bit()); } else if (type == mtpc_messageActionNoForwardsRequest) { const auto &data = action.c_messageActionNoForwardsRequest(); const auto expired = data.is_expired(); @@ -6708,7 +6715,7 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { auto prepareNoForwardsRequest = [this](const MTPDmessageActionNoForwardsRequest &action) { auto result = PreparedServiceText(); const auto nfr = Get(); - if (nfr && nfr->expired) { + if (nfr && nfr->expired && !nfr->actionTaken) { result.text = tr::lng_action_no_forwards_request_expired( tr::now, tr::marked); diff --git a/Telegram/SourceFiles/history/history_item_components.h b/Telegram/SourceFiles/history/history_item_components.h index 213977e7e6..0bf0d3a1ee 100644 --- a/Telegram/SourceFiles/history/history_item_components.h +++ b/Telegram/SourceFiles/history/history_item_components.h @@ -744,6 +744,11 @@ struct HistoryServiceNoForwardsRequest TimeId expiresAt = 0; mtpRequestId requestId = 0; bool expired = false; + bool actionTaken = false; +}; + +struct HistoryServiceNoForwardsToggle +: RuntimeComponent { }; struct HistoryServiceGameScore diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index 7488aeb06c..62c48e016a 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -1549,7 +1549,7 @@ void Element::refreshMedia(Element *replacing) { std::make_unique(this, emoji)); } } else if (const auto nfr = item->Get() - ; nfr && !nfr->expired) { + ; nfr && (!nfr->expired || nfr->actionTaken)) { _media = std::make_unique( this, GenerateNoForwardsRequestMedia(this, nfr),