@atlaskit/editor-card-provider 6.8.3 → 6.8.5
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/CHANGELOG.md +14 -0
- package/dist/cjs/api.js +18 -18
- package/dist/cjs/provider.js +173 -192
- package/dist/es2019/provider.js +16 -37
- package/dist/esm/api.js +18 -18
- package/dist/esm/provider.js +173 -192
- package/package.json +3 -3
package/dist/es2019/provider.js
CHANGED
|
@@ -160,48 +160,27 @@ export class EditorCardProvider extends NodeDataProvider {
|
|
|
160
160
|
// if we can load a response from cache, use it first
|
|
161
161
|
const key = this.nodeDataKey(jsonNode);
|
|
162
162
|
const details = this.smartCardLocalCacheClient.getItem(key);
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// if parent class NodeDataProvider has cached the network request for the node
|
|
173
|
-
// we can skip fetching the data async and updating the session storage cache
|
|
174
|
-
if (isResolvedCachedResponse && this.getCacheStatusForNode(jsonNode) === 'network') {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
} else {
|
|
178
|
-
if (details) {
|
|
179
|
-
callback({
|
|
180
|
-
data: details
|
|
181
|
-
});
|
|
182
|
-
}
|
|
163
|
+
// NAVX-4712: Handle responses with non-resolved statuses that were previously cached
|
|
164
|
+
const isResolvedCachedResponse = details && details.meta && getStatus(details) === 'resolved';
|
|
165
|
+
if (isResolvedCachedResponse) {
|
|
166
|
+
callback({
|
|
167
|
+
data: details
|
|
168
|
+
});
|
|
169
|
+
}
|
|
183
170
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
171
|
+
// if parent class NodeDataProvider has cached the network request for the node
|
|
172
|
+
// we can skip fetching the data async and updating the session storage cache
|
|
173
|
+
if (isResolvedCachedResponse && this.getCacheStatusForNode(jsonNode) === 'network') {
|
|
174
|
+
return;
|
|
190
175
|
}
|
|
191
176
|
|
|
192
177
|
// fetch the latest data async and update the session storage cache
|
|
193
178
|
this.getDataAsync(node, payload => {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
this.smartCardLocalCacheClient.setItem(key, response);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
} else {
|
|
203
|
-
if (payload.data && !payload.error) {
|
|
204
|
-
this.smartCardLocalCacheClient.setItem(key, payload.data);
|
|
179
|
+
const response = payload.data;
|
|
180
|
+
if (!payload.error && response !== null && response !== void 0 && response.meta) {
|
|
181
|
+
const status = getStatus(response);
|
|
182
|
+
if (status === 'resolved') {
|
|
183
|
+
this.smartCardLocalCacheClient.setItem(key, response);
|
|
205
184
|
}
|
|
206
185
|
}
|
|
207
186
|
callback(payload);
|
package/dist/esm/api.js
CHANGED
|
@@ -32,8 +32,8 @@ function _request() {
|
|
|
32
32
|
_request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(method, url,
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
34
|
data, headers) {
|
|
35
|
-
var requestConfig, response;
|
|
36
|
-
return _regeneratorRuntime.wrap(function
|
|
35
|
+
var requestConfig, response, _t;
|
|
36
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
37
37
|
while (1) switch (_context.prev = _context.next) {
|
|
38
38
|
case 0:
|
|
39
39
|
requestConfig = _objectSpread({
|
|
@@ -48,35 +48,35 @@ function _request() {
|
|
|
48
48
|
body: JSON.stringify(data)
|
|
49
49
|
} : {});
|
|
50
50
|
_context.prev = 1;
|
|
51
|
-
_context.next =
|
|
51
|
+
_context.next = 2;
|
|
52
52
|
return fetch(url, requestConfig);
|
|
53
|
-
case
|
|
53
|
+
case 2:
|
|
54
54
|
response = _context.sent;
|
|
55
55
|
if (!(response.ok || ALLOWED_RESPONSE_STATUS_CODES.includes(response.status))) {
|
|
56
|
-
_context.next =
|
|
56
|
+
_context.next = 4;
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
59
|
-
_context.next =
|
|
59
|
+
_context.next = 3;
|
|
60
60
|
return response.json();
|
|
61
|
-
case
|
|
61
|
+
case 3:
|
|
62
62
|
return _context.abrupt("return", _context.sent);
|
|
63
|
-
case
|
|
63
|
+
case 4:
|
|
64
64
|
throw response;
|
|
65
|
-
case
|
|
66
|
-
_context.prev =
|
|
67
|
-
|
|
68
|
-
if (!(typeof
|
|
69
|
-
_context.next =
|
|
65
|
+
case 5:
|
|
66
|
+
_context.prev = 5;
|
|
67
|
+
_t = _context["catch"](1);
|
|
68
|
+
if (!(typeof _t === 'string' || _t instanceof TypeError)) {
|
|
69
|
+
_context.next = 6;
|
|
70
70
|
break;
|
|
71
71
|
}
|
|
72
|
-
throw new NetworkError(
|
|
73
|
-
case
|
|
74
|
-
throw
|
|
75
|
-
case
|
|
72
|
+
throw new NetworkError(_t);
|
|
73
|
+
case 6:
|
|
74
|
+
throw _t;
|
|
75
|
+
case 7:
|
|
76
76
|
case "end":
|
|
77
77
|
return _context.stop();
|
|
78
78
|
}
|
|
79
|
-
}, _callee, null, [[1,
|
|
79
|
+
}, _callee, null, [[1, 5]]);
|
|
80
80
|
}));
|
|
81
81
|
return _request.apply(this, arguments);
|
|
82
82
|
}
|