mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 22:25:12 +00:00
Move caption to the next album item on cancel.
After #4869 albums are sent with captions in the first media. In case we cancel the first media leaving the rest of the album the caption will be lost unless we move it to the new "first" media.
This commit is contained in:
@@ -4898,37 +4898,13 @@ void ApiWrap::sendAlbumWithUploaded(
|
||||
const auto albumIt = _sendingAlbums.find(groupId.raw());
|
||||
Assert(albumIt != _sendingAlbums.end());
|
||||
const auto &album = albumIt->second;
|
||||
|
||||
const auto proj = [](const SendingAlbum::Item &item) {
|
||||
return item.msgId;
|
||||
};
|
||||
const auto itemIt = ranges::find(album->items, localId, proj);
|
||||
Assert(itemIt != album->items.end());
|
||||
Assert(!itemIt->media);
|
||||
|
||||
auto caption = item->originalText();
|
||||
TextUtilities::Trim(caption);
|
||||
auto sentEntities = TextUtilities::EntitiesToMTP(
|
||||
caption.entities,
|
||||
TextUtilities::ConvertOption::SkipLocal);
|
||||
const auto flags = !sentEntities.v.isEmpty()
|
||||
? MTPDinputSingleMedia::Flag::f_entities
|
||||
: MTPDinputSingleMedia::Flag(0);
|
||||
|
||||
itemIt->media = MTP_inputSingleMedia(
|
||||
MTP_flags(flags),
|
||||
media,
|
||||
MTP_long(randomId),
|
||||
MTP_string(caption.text),
|
||||
sentEntities);
|
||||
|
||||
album->fillMedia(item, media, randomId);
|
||||
sendAlbumIfReady(album.get());
|
||||
}
|
||||
|
||||
void ApiWrap::sendAlbumWithCancelled(
|
||||
not_null<HistoryItem*> item,
|
||||
const MessageGroupId &groupId) {
|
||||
const auto localId = item->fullId();
|
||||
const auto albumIt = _sendingAlbums.find(groupId.raw());
|
||||
if (albumIt == _sendingAlbums.end()) {
|
||||
// Sometimes we destroy item being sent already after the album
|
||||
@@ -4940,14 +4916,7 @@ void ApiWrap::sendAlbumWithCancelled(
|
||||
return;
|
||||
}
|
||||
const auto &album = albumIt->second;
|
||||
|
||||
const auto proj = [](const SendingAlbum::Item &item) {
|
||||
return item.msgId;
|
||||
};
|
||||
const auto itemIt = ranges::find(album->items, localId, proj);
|
||||
Assert(itemIt != album->items.end());
|
||||
album->items.erase(itemIt);
|
||||
|
||||
album->removeItem(item);
|
||||
sendAlbumIfReady(album.get());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user