2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Use rpl for file download progress notifications.

This commit is contained in:
John Preston
2020-04-10 15:17:10 +04:00
parent bf616036b3
commit 97bab388ea
14 changed files with 125 additions and 142 deletions

View File

@@ -1252,53 +1252,6 @@ void MainWidget::exportTopBarHeightUpdated() {
}
}
void MainWidget::documentLoadProgress(FileLoader *loader) {
if (const auto documentId = loader ? loader->objId() : 0) {
documentLoadProgress(session().data().document(documentId));
}
}
void MainWidget::documentLoadProgress(DocumentData *document) {
session().data().requestDocumentViewRepaint(document);
session().documentUpdated.notify(document, true);
if (!document->loaded() && document->isAudioFile()) {
Media::Player::instance()->documentLoadProgress(document);
}
}
void MainWidget::documentLoadFailed(FileLoader *loader, bool started) {
const auto documentId = loader ? loader->objId() : 0;
if (!documentId) return;
const auto document = session().data().document(documentId);
if (started) {
const auto origin = loader->fileOrigin();
const auto failedFileName = loader->fileName();
Ui::show(Box<ConfirmBox>(tr::lng_download_finish_failed(tr::now), crl::guard(this, [=] {
Ui::hideLayer();
if (document) {
document->save(origin, failedFileName);
}
})));
} else {
// Sometimes we have LOCATION_INVALID error in documents / stickers.
// Sometimes FILE_REFERENCE_EXPIRED could not be handled.
//
//Ui::show(Box<ConfirmBox>(tr::lng_download_path_failed(tr::now), tr::lng_download_path_settings(tr::now), crl::guard(this, [=] {
// Global::SetDownloadPath(QString());
// Global::SetDownloadPathBookmark(QByteArray());
// Ui::show(Box<DownloadPathBox>());
// Global::RefDownloadPathChanged().notify();
//})));
}
if (document) {
if (document->loading()) document->cancel();
document->status = FileDownloadFailed;
}
}
void MainWidget::inlineResultLoadProgress(FileLoader *loader) {
//InlineBots::Result *result = InlineBots::resultFromLoader(loader);
//if (!result) return;