Commit cbd39626 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Flatpak: fix fetching status

Let the backend know when it's not fully loaded.
Properly emit the initialized signal.
parent 40a9fd65
......@@ -77,7 +77,6 @@ FlatpakBackend::FlatpakBackend(QObject* parent)
: AbstractResourcesBackend(parent)
, m_updater(new StandardBackendUpdater(this))
, m_reviews(AppStreamIntegration::global()->reviews())
, m_fetching(false)
, m_refreshAppstreamMetadataJobs(0)
, m_threadPool(new QThreadPool(this))
{
......@@ -551,7 +550,7 @@ void FlatpakBackend::finishInitialization()
loadInstalledApps();
checkForUpdates();
Q_EMIT initialized();
acquireFetching(false);
}
void FlatpakBackend::loadAppsFromAppstreamData()
......@@ -622,6 +621,7 @@ void FlatpakBackend::integrateRemote(FlatpakInstallation *flatpakInstallation, F
return metadata.components();
}));
const auto sourceName = source.name();
acquireFetching(true);
connect(fw, &QFutureWatcher<QList<AppStream::Component>>::finished, this, [this, fw, flatpakInstallation, appstreamIconsPath, sourceName]() {
const auto components = fw->result();
foreach (const AppStream::Component& appstreamComponent, components) {
......@@ -1057,12 +1057,19 @@ void FlatpakBackend::updateAppState(FlatpakInstallation *flatpakInstallation, Fl
}
}
void FlatpakBackend::setFetching(bool fetching)
void FlatpakBackend::acquireFetching(bool f)
{
if (m_fetching != fetching) {
m_fetching = fetching;
if (f)
m_isFetching++;
else
m_isFetching--;
if ((!f && m_isFetching==0) || (f && m_isFetching==1)) {
emit fetchingChanged();
}
if (m_isFetching==0)
Q_EMIT initialized();
}
int FlatpakBackend::updatesCount() const
......
......@@ -57,7 +57,7 @@ public:
Transaction* installApplication(AbstractResource* app) override;
Transaction* installApplication(AbstractResource* app, const AddonList& addons) override;
Transaction* removeApplication(AbstractResource* app) override;
bool isFetching() const override { return m_fetching; }
bool isFetching() const override { return m_isFetching>0; }
AbstractResource * resourceForFile(const QUrl & ) override;
void checkForUpdates() override;
QString displayName() const override;
......@@ -104,13 +104,13 @@ private:
bool updateAppSizeFromRemote(FlatpakInstallation *flatpakInstallation, FlatpakResource *resource);
void updateAppState(FlatpakInstallation *flatpakInstallation, FlatpakResource *resource);
void setFetching(bool fetching);
void acquireFetching(bool f);
QHash<QString, FlatpakResource*> m_resources;
StandardBackendUpdater *m_updater;
FlatpakSourcesBackend *m_sources = nullptr;
QSharedPointer<OdrsReviewsBackend> m_reviews;
bool m_fetching;
uint m_isFetching = 0;
uint m_refreshAppstreamMetadataJobs;
GCancellable *m_cancellable;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment