From 73db349f57651b70a36d6970fc8045766e2dbb91 Mon Sep 17 00:00:00 2001
From: Hangzhi Yu <hangzhi@protonmail.com>
Date: Tue, 17 Jan 2023 12:56:20 +0100
Subject: [PATCH] Only skip queries that have pollInterval set on
 offline/background

---
 aleksis/core/frontend/app/apollo.js | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/aleksis/core/frontend/app/apollo.js b/aleksis/core/frontend/app/apollo.js
index cc468b8e9..c1cf08a8b 100644
--- a/aleksis/core/frontend/app/apollo.js
+++ b/aleksis/core/frontend/app/apollo.js
@@ -50,9 +50,15 @@ const apolloOpts = {
   defaultClient: apolloClient,
   defaultOptions: {
     $query: {
-      skip: (vm) => {
-        // We only want to run this query when background activity is on and we are not reported offline
-        return !vm.$root.backgroundActive || vm.$root.offline;
+      skip: function (vm, queryKey) {
+        if (queryKey in vm.$_apollo.queries) {
+          // We only want to run this query when background activity is on and we are not reported offline
+          return !!(
+            vm.$_apollo.queries[queryKey].options.pollInterval &&
+            (!vm.$root.backgroundActive || vm.$root.offline)
+          );
+        }
+        return false;
       },
       error: ({ graphQLErrors, networkError }, vm) => {
         if (graphQLErrors) {
-- 
GitLab