@contentful/field-editor-reference 5.1.7 → 5.1.8
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 +6 -0
- package/dist/field-editor-reference.cjs.development.js +46 -32
- package/dist/field-editor-reference.cjs.development.js.map +1 -1
- package/dist/field-editor-reference.cjs.production.min.js +1 -1
- package/dist/field-editor-reference.cjs.production.min.js.map +1 -1
- package/dist/field-editor-reference.esm.js +46 -32
- package/dist/field-editor-reference.esm.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.1.8](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.1.7...@contentful/field-editor-reference@5.1.8) (2022-09-12)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **reference-editor:** re-introduce entity refetch when slide-in is closed ([#1233](https://github.com/contentful/field-editors/issues/1233)) ([7026521](https://github.com/contentful/field-editors/commit/7026521d3c1885dbe61acd9dfc7a1e091a036565))
|
|
11
|
+
|
|
6
12
|
## [5.1.7](https://github.com/contentful/field-editors/compare/@contentful/field-editor-reference@5.1.6...@contentful/field-editor-reference@5.1.7) (2022-09-09)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @contentful/field-editor-reference
|
|
@@ -1967,13 +1967,13 @@ function _fetchContentfulEntry() {
|
|
|
1967
1967
|
_resourceId$split = resourceId.split('/'), spaceId = _resourceId$split[1], entryId = _resourceId$split[3];
|
|
1968
1968
|
environmentId = 'master';
|
|
1969
1969
|
_context3.next = 6;
|
|
1970
|
-
return Promise.all([fetch(['space', spaceId], function (
|
|
1971
|
-
var cmaClient =
|
|
1970
|
+
return Promise.all([fetch(['space', spaceId], function (_ref10) {
|
|
1971
|
+
var cmaClient = _ref10.cmaClient;
|
|
1972
1972
|
return cmaClient.space.get({
|
|
1973
1973
|
spaceId: spaceId
|
|
1974
1974
|
});
|
|
1975
|
-
}, options), fetch(['entry', spaceId, environmentId, entryId], function (
|
|
1976
|
-
var cmaClient =
|
|
1975
|
+
}, options), fetch(['entry', spaceId, environmentId, entryId], function (_ref11) {
|
|
1976
|
+
var cmaClient = _ref11.cmaClient;
|
|
1977
1977
|
return cmaClient.entry.get({
|
|
1978
1978
|
spaceId: spaceId,
|
|
1979
1979
|
environmentId: environmentId,
|
|
@@ -1987,15 +1987,15 @@ function _fetchContentfulEntry() {
|
|
|
1987
1987
|
entry = _yield$Promise$all[1];
|
|
1988
1988
|
contentTypeId = entry.sys.contentType.sys.id;
|
|
1989
1989
|
_context3.next = 12;
|
|
1990
|
-
return Promise.all([fetch(['contentType', spaceId, environmentId, contentTypeId], function (
|
|
1991
|
-
var cmaClient =
|
|
1990
|
+
return Promise.all([fetch(['contentType', spaceId, environmentId, contentTypeId], function (_ref12) {
|
|
1991
|
+
var cmaClient = _ref12.cmaClient;
|
|
1992
1992
|
return cmaClient.contentType.get({
|
|
1993
1993
|
contentTypeId: contentTypeId,
|
|
1994
1994
|
spaceId: spaceId,
|
|
1995
1995
|
environmentId: environmentId
|
|
1996
1996
|
});
|
|
1997
1997
|
}, options), fetch(['defaultLocale', spaceId, environmentId], /*#__PURE__*/function () {
|
|
1998
|
-
var
|
|
1998
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref13) {
|
|
1999
1999
|
var _locales$items$find;
|
|
2000
2000
|
|
|
2001
2001
|
var cmaClient, locales, defaultLocaleCode;
|
|
@@ -2003,7 +2003,7 @@ function _fetchContentfulEntry() {
|
|
|
2003
2003
|
while (1) {
|
|
2004
2004
|
switch (_context2.prev = _context2.next) {
|
|
2005
2005
|
case 0:
|
|
2006
|
-
cmaClient =
|
|
2006
|
+
cmaClient = _ref13.cmaClient;
|
|
2007
2007
|
_context2.next = 3;
|
|
2008
2008
|
return cmaClient.locale.getMany({
|
|
2009
2009
|
spaceId: spaceId,
|
|
@@ -2029,7 +2029,7 @@ function _fetchContentfulEntry() {
|
|
|
2029
2029
|
}));
|
|
2030
2030
|
|
|
2031
2031
|
return function (_x3) {
|
|
2032
|
-
return
|
|
2032
|
+
return _ref14.apply(this, arguments);
|
|
2033
2033
|
};
|
|
2034
2034
|
}(), options)]);
|
|
2035
2035
|
|
|
@@ -2222,14 +2222,34 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2222
2222
|
|
|
2223
2223
|
// @ts-expect-error ...
|
|
2224
2224
|
var onEntityChanged = props.sdk.space.onEntityChanged;
|
|
2225
|
+
var onSlideInNavigation = props.sdk.navigator.onSlideInNavigation;
|
|
2225
2226
|
React.useEffect(function () {
|
|
2227
|
+
function findSameSpaceQueries() {
|
|
2228
|
+
return queryCache.findAll({
|
|
2229
|
+
type: 'active',
|
|
2230
|
+
predicate: function predicate(query) {
|
|
2231
|
+
return isSameSpaceEntityQueryKey(query.queryKey);
|
|
2232
|
+
}
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2226
2236
|
if (typeof onEntityChanged !== 'function') {
|
|
2227
|
-
return
|
|
2237
|
+
return onSlideInNavigation(function (_ref4) {
|
|
2238
|
+
var oldSlideLevel = _ref4.oldSlideLevel,
|
|
2239
|
+
newSlideLevel = _ref4.newSlideLevel;
|
|
2240
|
+
|
|
2241
|
+
if (oldSlideLevel > newSlideLevel) {
|
|
2242
|
+
findSameSpaceQueries().forEach(function (query) {
|
|
2243
|
+
// automatically refetches the query
|
|
2244
|
+
void queryClient.invalidateQueries(query.queryKey);
|
|
2245
|
+
});
|
|
2246
|
+
}
|
|
2247
|
+
});
|
|
2228
2248
|
}
|
|
2229
2249
|
|
|
2230
|
-
var subscribeQuery = function subscribeQuery(
|
|
2231
|
-
var queryKey =
|
|
2232
|
-
queryHash =
|
|
2250
|
+
var subscribeQuery = function subscribeQuery(_ref5) {
|
|
2251
|
+
var queryKey = _ref5.queryKey,
|
|
2252
|
+
queryHash = _ref5.queryHash;
|
|
2233
2253
|
var entityType = queryKey[0],
|
|
2234
2254
|
entityId = queryKey[1];
|
|
2235
2255
|
entityChangeUnsubscribers.current[queryHash] = onEntityChanged(entityType, entityId, function (data) {
|
|
@@ -2237,13 +2257,7 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2237
2257
|
});
|
|
2238
2258
|
};
|
|
2239
2259
|
|
|
2240
|
-
|
|
2241
|
-
type: 'active',
|
|
2242
|
-
predicate: function predicate(query) {
|
|
2243
|
-
return isSameSpaceEntityQueryKey(query.queryKey);
|
|
2244
|
-
}
|
|
2245
|
-
});
|
|
2246
|
-
queries.forEach(subscribeQuery);
|
|
2260
|
+
findSameSpaceQueries().forEach(subscribeQuery);
|
|
2247
2261
|
var unsubscribe = queryCache.subscribe(function (event) {
|
|
2248
2262
|
if (!event) {
|
|
2249
2263
|
return;
|
|
@@ -2276,7 +2290,7 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2276
2290
|
});
|
|
2277
2291
|
entityChangeUnsubscribers.current = {};
|
|
2278
2292
|
};
|
|
2279
|
-
}, [onEntityChanged, queryCache, isSameSpaceEntityQueryKey, queryClient]);
|
|
2293
|
+
}, [onEntityChanged, queryCache, isSameSpaceEntityQueryKey, queryClient, getEntity, onSlideInNavigation]);
|
|
2280
2294
|
return {
|
|
2281
2295
|
ids: props.sdk.ids,
|
|
2282
2296
|
cmaClient: cmaClient,
|
|
@@ -2285,22 +2299,22 @@ var _constate = /*#__PURE__*/constate(function useInitServices(props) {
|
|
|
2285
2299
|
getEntity: getEntity,
|
|
2286
2300
|
getEntityScheduledActions: getEntityScheduledActions
|
|
2287
2301
|
};
|
|
2288
|
-
}, function (_ref5) {
|
|
2289
|
-
var fetch = _ref5.fetch;
|
|
2290
|
-
return fetch;
|
|
2291
2302
|
}, function (_ref6) {
|
|
2292
|
-
var
|
|
2293
|
-
|
|
2294
|
-
|
|
2303
|
+
var fetch = _ref6.fetch;
|
|
2304
|
+
return fetch;
|
|
2305
|
+
}, function (_ref7) {
|
|
2306
|
+
var getResource = _ref7.getResource,
|
|
2307
|
+
getEntity = _ref7.getEntity,
|
|
2308
|
+
getEntityScheduledActions = _ref7.getEntityScheduledActions;
|
|
2295
2309
|
return {
|
|
2296
2310
|
getResource: getResource,
|
|
2297
2311
|
getEntity: getEntity,
|
|
2298
2312
|
getEntityScheduledActions: getEntityScheduledActions
|
|
2299
2313
|
};
|
|
2300
|
-
}, function (
|
|
2314
|
+
}, function (_ref8) {
|
|
2301
2315
|
var _ids$environmentAlias;
|
|
2302
2316
|
|
|
2303
|
-
var ids =
|
|
2317
|
+
var ids = _ref8.ids;
|
|
2304
2318
|
return {
|
|
2305
2319
|
environment: (_ids$environmentAlias = ids.environmentAlias) != null ? _ids$environmentAlias : ids.environment,
|
|
2306
2320
|
space: ids.space
|
|
@@ -2357,9 +2371,9 @@ function useResource(resourceType, urn, options) {
|
|
|
2357
2371
|
};
|
|
2358
2372
|
}
|
|
2359
2373
|
|
|
2360
|
-
function EntityProvider(
|
|
2361
|
-
var children =
|
|
2362
|
-
props = _objectWithoutPropertiesLoose(
|
|
2374
|
+
function EntityProvider(_ref9) {
|
|
2375
|
+
var children = _ref9.children,
|
|
2376
|
+
props = _objectWithoutPropertiesLoose(_ref9, _excluded2);
|
|
2363
2377
|
|
|
2364
2378
|
var reactQueryClient = React.useMemo(function () {
|
|
2365
2379
|
var queryCache = new reactQuery.QueryCache();
|