Fixed bookmarks catalog downloading

This commit is contained in:
r.kuznetsov 2018-06-22 15:09:14 +03:00 committed by Daria Volvenkova
parent a4fc4fda51
commit 47ff146fb8
2 changed files with 19 additions and 6 deletions

View file

@ -89,11 +89,20 @@ void BookmarkCatalog::Download(std::string const & id, std::string const & name,
{
if (startHandler)
startHandler();
}, [finishHandler = std::move(finishHandler)] (platform::RemoteFile::Result && result,
std::string const & filePath)
}, [this, id, finishHandler = std::move(finishHandler)] (platform::RemoteFile::Result && result,
std::string const & filePath) mutable
{
if (finishHandler)
finishHandler(std::move(result), filePath);
GetPlatform().RunTask(Platform::Thread::Gui, [this, id, result = std::move(result), filePath,
finishHandler = std::move(finishHandler)]() mutable
{
if (result.m_status == platform::RemoteFile::Status::Ok)
RegisterDownloadedId(id);
else
m_downloadingIds.erase(id);
if (finishHandler)
finishHandler(std::move(result), filePath);
});
});
}

View file

@ -2094,8 +2094,12 @@ void BookmarkManager::ImportDownloadedFromCatalog(std::string const & id, std::s
}
else
{
if (m_onCatalogImportFinished)
m_onCatalogImportFinished(id, false /* successful */);
GetPlatform().RunTask(Platform::Thread::Gui, [this, id]
{
m_bookmarkCatalog.UnregisterDownloadedId(id);
if (m_onCatalogImportFinished)
m_onCatalogImportFinished(id, false /* successful */);
});
}
});
}