@docbrasil/api-systemmanager 1.1.45 → 1.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/dispatch.js +5 -3
- package/dist/bundle.cjs +3 -3
- package/dist/bundle.mjs +1 -1
- package/package.json +1 -1
package/api/dispatch.js
CHANGED
|
@@ -13,12 +13,13 @@ class Dispatch {
|
|
|
13
13
|
const self = this;
|
|
14
14
|
self.parent = options.parent;
|
|
15
15
|
self._cache = options.cache;
|
|
16
|
+
self._forceCache = options.forceCache;
|
|
16
17
|
self._client = Axios.create({baseURL: self.parent.options.uri, withCredentials: true});
|
|
17
18
|
|
|
18
19
|
// Add request interceptor for offline handling
|
|
19
20
|
self._client.interceptors.request.use(
|
|
20
21
|
async (config) => {
|
|
21
|
-
if (self._isOnline()) {
|
|
22
|
+
if (self._isOnline() || !self._cache) {
|
|
22
23
|
return config;
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -55,7 +56,7 @@ class Dispatch {
|
|
|
55
56
|
self._client.interceptors.response.use(
|
|
56
57
|
async response => {
|
|
57
58
|
// Cache successful responses when online
|
|
58
|
-
if (response.status === 200 && self._isOnline()) {
|
|
59
|
+
if (response.status === 200 && self._isOnline() && self._cache) {
|
|
59
60
|
await self._setCache(response.config.url, {
|
|
60
61
|
method: response.config.method,
|
|
61
62
|
data: response.config.data,
|
|
@@ -110,7 +111,8 @@ class Dispatch {
|
|
|
110
111
|
* @private
|
|
111
112
|
*/
|
|
112
113
|
_isOnline() {
|
|
113
|
-
|
|
114
|
+
if(this._forceCache) return false;
|
|
115
|
+
return typeof navigator !== 'undefined' && navigator.onLine;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
/**
|
package/dist/bundle.cjs
CHANGED
|
@@ -30,7 +30,7 @@ class Dispatch {
|
|
|
30
30
|
// Add request interceptor for offline handling
|
|
31
31
|
self._client.interceptors.request.use(
|
|
32
32
|
async (config) => {
|
|
33
|
-
if (self._isOnline()) {
|
|
33
|
+
if (self._isOnline() || !self._cache) {
|
|
34
34
|
return config;
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -67,7 +67,7 @@ class Dispatch {
|
|
|
67
67
|
self._client.interceptors.response.use(
|
|
68
68
|
async response => {
|
|
69
69
|
// Cache successful responses when online
|
|
70
|
-
if (response.status === 200 && self._isOnline()) {
|
|
70
|
+
if (response.status === 200 && self._isOnline() && self._cache) {
|
|
71
71
|
await self._setCache(response.config.url, {
|
|
72
72
|
method: response.config.method,
|
|
73
73
|
data: response.config.data,
|
|
@@ -122,7 +122,7 @@ class Dispatch {
|
|
|
122
122
|
* @private
|
|
123
123
|
*/
|
|
124
124
|
_isOnline() {
|
|
125
|
-
return typeof navigator !== 'undefined' && navigator.onLine
|
|
125
|
+
return typeof navigator !== 'undefined' && navigator.onLine;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/**
|