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