diff --git a/Telegram/SourceFiles/data/data_file_click_handler.cpp b/Telegram/SourceFiles/data/data_file_click_handler.cpp index 9fee965f50..ec746f5667 100644 --- a/Telegram/SourceFiles/data/data_file_click_handler.cpp +++ b/Telegram/SourceFiles/data/data_file_click_handler.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_download_manager.h" #include "data/data_photo.h" +#include "main/main_session.h" FileClickHandler::FileClickHandler(FullMsgId context) : _context(context) { @@ -79,7 +80,14 @@ void DocumentSaveClickHandler::Save( } auto savename = QString(); - if (mode != Mode::ToCacheOrFile || !data->saveToCache()) { + if (mode == Mode::ToCacheOrFile && data->saveToCache()) { + data->save(origin, savename); + return; + } + InvokeQueued(qApp, crl::guard(&data->session(), [=] { + // If we call file dialog synchronously, it will stop + // background thread timers from working which would + // stop audio playback in voice chats / live streams. if (mode != Mode::ToNewFile && data->saveFromData()) { return; } @@ -92,16 +100,15 @@ void DocumentSaveClickHandler::Save( const auto filename = filepath.isEmpty() ? QString() : fileinfo.fileName(); - savename = DocumentFileNameForSave( + const auto savename = DocumentFileNameForSave( data, (mode == Mode::ToNewFile), filename, filedir); - if (savename.isEmpty()) { - return; + if (!savename.isEmpty()) { + data->save(origin, savename); } - } - data->save(origin, savename); + })); } void DocumentSaveClickHandler::SaveAndTrack(