mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-01 17:57:51 +00:00
Try showing as expired only requests without actions.
This commit is contained in:
@@ -1561,6 +1561,19 @@ void History::addItemToBlock(not_null<HistoryItem*> item) {
|
||||
const auto view = block->messages.back().get();
|
||||
view->attachToBlock(block, block->messages.size() - 1);
|
||||
|
||||
if (item->Has<HistoryServiceNoForwardsToggle>()) {
|
||||
if (const auto prev = view->previousInBlocks()) {
|
||||
if (const auto nfr = prev->data()->Get<HistoryServiceNoForwardsRequest>()) {
|
||||
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<HistoryServiceNoForwardsToggle>()) {
|
||||
const auto last = block->messages.back()->data();
|
||||
if (const auto nfr = last->Get<HistoryServiceNoForwardsRequest>()) {
|
||||
if (!nfr->actionTaken) {
|
||||
nfr->actionTaken = true;
|
||||
if (nfr->expired) {
|
||||
owner().requestItemViewRefresh(last);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
block->messages.back()->nextInBlocksRemoved();
|
||||
}
|
||||
|
||||
@@ -2162,6 +2162,8 @@ void HistoryItem::setStoryFields(not_null<Data::Story*> story) {
|
||||
}
|
||||
|
||||
void HistoryItem::applyEdition(const MTPDmessageService &message) {
|
||||
const auto wasNfr = Get<HistoryServiceNoForwardsRequest>();
|
||||
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<HistoryServiceNoForwardsRequest>()) {
|
||||
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<HistoryServiceNoForwardsRequest>();
|
||||
if (nfr && nfr->expired) {
|
||||
if (nfr && nfr->expired && !nfr->actionTaken) {
|
||||
result.text = tr::lng_action_no_forwards_request_expired(
|
||||
tr::now,
|
||||
tr::marked);
|
||||
|
||||
@@ -744,6 +744,11 @@ struct HistoryServiceNoForwardsRequest
|
||||
TimeId expiresAt = 0;
|
||||
mtpRequestId requestId = 0;
|
||||
bool expired = false;
|
||||
bool actionTaken = false;
|
||||
};
|
||||
|
||||
struct HistoryServiceNoForwardsToggle
|
||||
: RuntimeComponent<HistoryServiceNoForwardsToggle, HistoryItem> {
|
||||
};
|
||||
|
||||
struct HistoryServiceGameScore
|
||||
|
||||
@@ -1549,7 +1549,7 @@ void Element::refreshMedia(Element *replacing) {
|
||||
std::make_unique<LargeEmoji>(this, emoji));
|
||||
}
|
||||
} else if (const auto nfr = item->Get<HistoryServiceNoForwardsRequest>()
|
||||
; nfr && !nfr->expired) {
|
||||
; nfr && (!nfr->expired || nfr->actionTaken)) {
|
||||
_media = std::make_unique<MediaGeneric>(
|
||||
this,
|
||||
GenerateNoForwardsRequestMedia(this, nfr),
|
||||
|
||||
Reference in New Issue
Block a user