mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
parent
9b74958fab
commit
fd47fd4d9e
4 changed files with 27 additions and 6 deletions
|
@ -148,6 +148,7 @@ void EditMessageWithUploadedMedia(
|
|||
MTPInputMedia media) {
|
||||
const auto done = [=](Fn<void()> applyUpdates) {
|
||||
if (item) {
|
||||
item->removeFromSharedMediaIndex();
|
||||
item->clearSavedMedia();
|
||||
item->setIsLocalUpdateMedia(true);
|
||||
applyUpdates();
|
||||
|
|
|
@ -845,18 +845,17 @@ not_null<HistoryItem*> History::addNewToBack(
|
|||
addItemToBlock(item);
|
||||
|
||||
if (!unread && item->isRegular()) {
|
||||
if (const auto sharedMediaTypes = item->sharedMediaTypes()) {
|
||||
if (const auto types = item->sharedMediaTypes()) {
|
||||
auto from = loadedAtTop() ? 0 : minMsgId();
|
||||
auto till = loadedAtBottom() ? ServerMaxMsgId : maxMsgId();
|
||||
auto &storage = session().storage();
|
||||
storage.add(Storage::SharedMediaAddExisting(
|
||||
peer->id,
|
||||
MsgId(0), // topicRootId
|
||||
sharedMediaTypes,
|
||||
types,
|
||||
item->id,
|
||||
{ from, till }));
|
||||
const auto pinned = sharedMediaTypes.test(
|
||||
Storage::SharedMediaType::Pinned);
|
||||
const auto pinned = types.test(Storage::SharedMediaType::Pinned);
|
||||
if (pinned) {
|
||||
setHasPinnedMessages(true);
|
||||
}
|
||||
|
@ -864,7 +863,7 @@ not_null<HistoryItem*> History::addNewToBack(
|
|||
storage.add(Storage::SharedMediaAddExisting(
|
||||
peer->id,
|
||||
topic->rootId(),
|
||||
sharedMediaTypes,
|
||||
types,
|
||||
item->id,
|
||||
{ item->id, item->id}));
|
||||
if (pinned) {
|
||||
|
|
|
@ -1395,6 +1395,7 @@ void HistoryItem::applyEdition(HistoryMessageEdition &&edition) {
|
|||
setReplyMarkup(base::take(edition.replyMarkup));
|
||||
}
|
||||
if (!isLocalUpdateMedia()) {
|
||||
removeFromSharedMediaIndex();
|
||||
refreshMedia(edition.mtpMedia);
|
||||
}
|
||||
if (!edition.useSameReactions) {
|
||||
|
@ -1405,6 +1406,9 @@ void HistoryItem::applyEdition(HistoryMessageEdition &&edition) {
|
|||
setText(_media
|
||||
? edition.textWithEntities
|
||||
: EnsureNonEmpty(edition.textWithEntities));
|
||||
if (!isLocalUpdateMedia()) {
|
||||
indexAsNewItem();
|
||||
}
|
||||
if (!edition.useSameReplies) {
|
||||
if (!edition.replies.isNull) {
|
||||
if (checkRepliesPts(edition.replies)) {
|
||||
|
@ -1424,6 +1428,7 @@ void HistoryItem::applyEdition(const MTPDmessageService &message) {
|
|||
if (message.vaction().type() == mtpc_messageActionHistoryClear) {
|
||||
const auto wasGrouped = history()->owner().groups().isGrouped(this);
|
||||
setReplyMarkup({});
|
||||
removeFromSharedMediaIndex();
|
||||
refreshMedia(nullptr);
|
||||
setTextValue({});
|
||||
changeViewsCount(-1);
|
||||
|
@ -1653,7 +1658,10 @@ void HistoryItem::destroyHistoryEntry() {
|
|||
|
||||
Storage::SharedMediaTypesMask HistoryItem::sharedMediaTypes() const {
|
||||
auto result = Storage::SharedMediaTypesMask {};
|
||||
if (const auto media = this->media()) {
|
||||
const auto media = _savedLocalEditMediaData
|
||||
? _savedLocalEditMediaData->media.get()
|
||||
: _media.get();
|
||||
if (media) {
|
||||
result.set(media->sharedMediaTypes());
|
||||
}
|
||||
if (hasTextLinks()) {
|
||||
|
@ -1684,6 +1692,18 @@ void HistoryItem::indexAsNewItem() {
|
|||
}
|
||||
}
|
||||
|
||||
void HistoryItem::removeFromSharedMediaIndex() {
|
||||
if (isRegular()) {
|
||||
if (const auto types = sharedMediaTypes()) {
|
||||
_history->session().storage().remove(
|
||||
Storage::SharedMediaRemoveOne(
|
||||
_history->peer->id,
|
||||
types,
|
||||
id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryItem::incrementReplyToTopCounter() {
|
||||
if (const auto reply = Get<HistoryMessageReply>()) {
|
||||
changeReplyToTopCounter(reply, 1);
|
||||
|
|
|
@ -346,6 +346,7 @@ public:
|
|||
[[nodiscard]] Storage::SharedMediaTypesMask sharedMediaTypes() const;
|
||||
|
||||
void indexAsNewItem();
|
||||
void removeFromSharedMediaIndex();
|
||||
|
||||
[[nodiscard]] QString notificationHeader() const;
|
||||
[[nodiscard]] TextWithEntities notificationText() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue