File 0002-Add-a-granular-cache-preference-thing-to-attica-kde.patch of Package plasma5-desktop.17405

From a6e749b3d1825986ca54981a3b9a98fb72b4c059 Mon Sep 17 00:00:00 2001
From: Dan Leinir Turthra Jensen <admin@leinir.dk>
Date: Tue, 8 Feb 2022 11:16:16 +0000
Subject: [PATCH 2/5] Add a granular cache preference thing to attica-kde

This allows us to explicitly add cache preference to specific calls.
Usually attica calls want to be very current, but in some cases we can
assume things aren't going to change often (such as the categories
call), and we can just use the cached version for those calls.

(cherry picked from commit 798027fd17ab86eea022e5d269aa86138b28b130)
---
 attica-kde/kdeplugin/kdeplatformdependent.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/attica-kde/kdeplugin/kdeplatformdependent.cpp b/attica-kde/kdeplugin/kdeplatformdependent.cpp
index ea5fc4cb7..c0faa2b0c 100644
--- a/attica-kde/kdeplugin/kdeplatformdependent.cpp
+++ b/attica-kde/kdeplugin/kdeplatformdependent.cpp
@@ -96,6 +96,18 @@ QNetworkRequest KdePlatformDependent::removeAuthFromRequest(const QNetworkReques
     const QStringList noauth = { QStringLiteral("no-auth-prompt"), QStringLiteral("true") };
     QNetworkRequest notConstReq = const_cast<QNetworkRequest&>(request);
     notConstReq.setAttribute(QNetworkRequest::User, noauth);
+
+    // Add cache preference in a granular fashion (we will almost certainly want more of these, but...)
+    static const QList<QString> preferCacheEndpoints{
+        QLatin1String{"/content/categories"}
+    }
+    for (const QString &endpoint : preferCacheEndpoints) {
+        if (notConstReq.url().endsWith()) {
+            notConstReq.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
+            break;
+        }
+    }
+
     return notConstReq;
 }
 
-- 
2.33.1

openSUSE Build Service is sponsored by