mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
fix: invert media & downloading state & media without filename
This commit is contained in:
@@ -38,8 +38,7 @@ bool isForwarding(const PeerId &id) {
|
||||
return state.state != ForwardState::State::Finished
|
||||
&& state.currentChunk < state.totalChunks
|
||||
&& !state.stopRequested
|
||||
&& state.totalChunks
|
||||
&& state.totalMessages;
|
||||
&& (state.totalChunks && state.totalMessages || state.state == ForwardState::State::Downloading);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -85,7 +84,7 @@ std::pair<QString, QString> stateName(const PeerId &id) {
|
||||
if (state->state == ForwardState::State::Preparing) {
|
||||
status = tr::ayu_AyuForwardStatusPreparing(tr::now);
|
||||
} else if (state->state == ForwardState::State::Downloading) {
|
||||
status = tr::ayu_AyuForwardStatusLoadingMedia(tr::now);
|
||||
return std::make_pair(tr::ayu_AyuForwardStatusLoadingMedia(tr::now), "");
|
||||
} else if (state->state == ForwardState::State::Sending) {
|
||||
status = tr::ayu_AyuForwardStatusForwarding(tr::now);
|
||||
} else {
|
||||
@@ -367,6 +366,7 @@ void forwardMessages(
|
||||
}
|
||||
|
||||
auto message = Api::MessageToSend(Api::SendAction(session->data().history(peer->id)));
|
||||
message.action.options.invertCaption = item->invertMedia();
|
||||
message.action.replyTo = action.replyTo;
|
||||
|
||||
if (draft.options != Data::ForwardOptions::NoNamesAndCaptions) {
|
||||
|
||||
@@ -85,6 +85,17 @@ QString filePath(not_null<Main::Session*> session, const Data::Media *media) {
|
||||
return pathForSave(session) + "round_" + QString::number(document->getDC()) + "_" +
|
||||
QString::number(document->id) + ".mp4";
|
||||
}
|
||||
|
||||
|
||||
// media without any file name
|
||||
if (document->isGifv()) {
|
||||
return pathForSave(session) + "gif_" + QString::number(document->getDC()) + "_" +
|
||||
QString::number(document->id) + ".gif";
|
||||
}
|
||||
if (document->isVideoFile()) {
|
||||
return pathForSave(session) + "video_" + QString::number(document->getDC()) + "_" +
|
||||
QString::number(document->id) + ".mp4";
|
||||
}
|
||||
} else if (const auto photo = media->photo()) {
|
||||
return pathForSave(session) + QString::number(photo->getDC()) + "_" + QString::number(photo->id) + ".jpg";
|
||||
}
|
||||
@@ -140,9 +151,8 @@ void loadDocumentSync(not_null<Main::Session*> session, DocumentData *data, not_
|
||||
{
|
||||
data->save(Data::FileOriginMessage(item->fullId()), path);
|
||||
|
||||
rpl::single() | rpl::then(
|
||||
session->downloaderTaskFinished()
|
||||
) | rpl::filter([&]
|
||||
|
||||
session->downloaderTaskFinished() | rpl::filter([&]
|
||||
{
|
||||
return data->status == FileDownloadFailed || fileSize(item) == data->size;
|
||||
}) | rpl::start_with_next([&]() mutable
|
||||
@@ -290,13 +300,13 @@ void sendDocumentSync(not_null<Main::Session*> session,
|
||||
SendMediaType type,
|
||||
TextWithTags &&caption,
|
||||
const Api::SendAction &action) {
|
||||
|
||||
auto groupId = std::make_shared<SendingAlbum>();
|
||||
groupId->groupId = base::RandomValue<uint64>();
|
||||
|
||||
crl::on_main([=, lst = std::move(group.list), caption = std::move(caption)]() mutable
|
||||
{
|
||||
session->api().sendFiles(std::move(lst), type, std::move(caption), groupId, action);
|
||||
auto size = lst.files.size();
|
||||
session->api().sendFiles(std::move(lst), type, std::move(caption), size > 1 ? groupId : nullptr, action);
|
||||
});
|
||||
|
||||
waitForMsgSync(session, action);
|
||||
|
||||
Reference in New Issue
Block a user