Commit 40cb2c8a authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

applets/comic: Use cached comics when there is no network connection

Previousely we would not cache comics whenever we do not have a next identifier
parent b24d3523
......@@ -55,6 +55,9 @@ QImage CachedProvider::image() const
QString CachedProvider::identifier() const
{
if (requestedString().lastIndexOf(QLatin1Char(':')) + 1 == requestedString().count()) {
return requestedString() + lastCachedStripIdentifier();
}
return requestedString();
}
......
......@@ -73,7 +73,7 @@ bool ComicEngine::requestSource(const QString &identifier, ComicRequestCallback
const QStringList parts = identifier.split(QLatin1Char(':'), Qt::KeepEmptyParts);
// check whether it is cached, make sure second part present
if (parts.count() > 1 && CachedProvider::isCached(identifier)) {
if (parts.count() > 1 && (CachedProvider::isCached(identifier) || !m_networkConfigurationManager.isOnline())) {
ComicProvider *provider = new CachedProvider(this, KPluginMetaData{}, ComicProvider::StringIdentifier, identifier);
m_jobs[identifier] = provider;
connect(provider, &ComicProvider::finished, this, [this, callback, provider]() {
......@@ -175,9 +175,7 @@ void ComicEngine::finished(ComicProvider *provider, ComicRequestCallback callbac
}
// store in cache if it's not the response of a CachedProvider,
// if there is a valid image and if there is a next comic
// (if we're on today's comic it could become stale)
if (!provider->inherits("CachedProvider") && !provider->image().isNull() && !provider->nextIdentifier().isEmpty()) {
if (!provider->inherits("CachedProvider") && !provider->image().isNull()) {
ComicMetaData info;
info.websiteUrl = provider->websiteUrl();
......
Supports Markdown
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