Jake Vanderwerf
4 hours ago 56a9a1ccf764ff7a6af8f8a2292cb07443cb4aa7
assets/js/concise/DataStore.js
@@ -85,6 +85,8 @@
               ignore: [],       //any filters to ignore when filtering store locally
               required: null,
               isAuth: false,
               // Cache
               TTL: 3600000, // 1 hour
               useHttpCaching: true,
@@ -542,11 +544,21 @@
         const controller = new AbortController();
         store.currentRequest = controller;
         const response = await fetch(url, {
            method: 'GET',
            headers,
            signal: controller.signal
         });
         let response;
         if (store.isAuth) {
            response = await window.auth.fetch(url, {
               method: 'GET',
               headers,
               signal: controller.signal
            });
         } else {
            response = await fetch(url, {
               method: 'GET',
               headers,
               signal: controller.signal
            });
         }
         if (!response.ok) {
            // Access the error details from the response body
            const errorBody = await response.text();
@@ -909,6 +921,7 @@
      if (type === 'object') {
         const processed = {};
         for (const [key, value] of Object.entries(obj)) {
            if (value === undefined) continue;
            const result = this.processForStorage(value, validate, `${path}.${key}`);
            if (!result.valid) return result;
            // Include null values, skip undefined
@@ -1114,7 +1127,12 @@
      // Handle other filters
      for (const [key, value] of Object.entries(store.filters)) {
         if (key === 'taxonomy') continue;
         if (key === 'taxonomy') {
            if (typeof value === 'string' && !value.includes(',')) {
               filterPredicates.push(item => item.taxonomy === value);
            }
            continue;
         }
         if (store.ignoreFilters.has(key)) {
            continue;
         }
@@ -1272,14 +1290,9 @@
      }
      if (store.lastResponse.has_more === false) {
         // Check if new filters are a subset of what we have
         const isSubsetFilter = Object.entries(updates).every(([key, value]) => {
            if (store.ignoreFilters.has(key)) return true;
            if (key === 'page') return true; // Handle pagination locally
            return true; // We have all data, can filter locally
         });
         if (isSubsetFilter) return false;
         if (this.hasCompleteData(store, store.filters)) {
            return false;
         }
      }
      if ('page' in updates) {