Skip to content

Commit

Permalink
do remote library update in a different thread
Browse files Browse the repository at this point in the history
Put updateRemoteLibrary in a new thread so it doesn't block the main UI, particularly the loader widget
  • Loading branch information
juuz0 committed Jul 3, 2023
1 parent e6082ef commit fb1fb8d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/contentmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "contentmanagerdelegate.h"
#include "node.h"
#include "kiwixconfirmbox.h"
#include <QtConcurrent/QtConcurrentRun>

ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader, QObject *parent)
: QObject(parent),
Expand Down Expand Up @@ -539,11 +540,13 @@ void ContentManager::updateLibrary() {

#define CATALOG_URL "library.kiwix.org"
void ContentManager::updateRemoteLibrary(const QString& content) {
m_remoteLibrary = kiwix::Library();
kiwix::Manager manager(&m_remoteLibrary);
manager.readOpds(content.toStdString(), CATALOG_URL);
emit(this->booksChanged());
emit(this->pendingRequest(false));
QtConcurrent::run([=]() {
m_remoteLibrary = kiwix::Library();
kiwix::Manager manager(&m_remoteLibrary);
manager.readOpds(content.toStdString(), CATALOG_URL);
emit(this->booksChanged());
emit(this->pendingRequest(false));
});
}

void ContentManager::setSearch(const QString &search)
Expand Down

0 comments on commit fb1fb8d

Please sign in to comment.