@atlaskit/editor-synced-block-provider 3.14.6 → 3.16.0
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 +18 -0
- package/dist/cjs/clients/block-service/blockSubscription.js +2 -1
- package/dist/cjs/hooks/useFetchSyncBlockData.js +6 -0
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +16 -6
- package/dist/es2019/clients/block-service/blockSubscription.js +2 -1
- package/dist/es2019/hooks/useFetchSyncBlockData.js +6 -0
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +15 -6
- package/dist/esm/clients/block-service/blockSubscription.js +2 -1
- package/dist/esm/hooks/useFetchSyncBlockData.js +6 -0
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +16 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 3.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`ff4d035bb0bda`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ff4d035bb0bda) -
|
|
8
|
+
EDITOR-2849 fix editor and live page ssr
|
|
9
|
+
|
|
10
|
+
## 3.15.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [`04b96fcb2ac43`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/04b96fcb2ac43) -
|
|
15
|
+
Use existing function to check if SSR
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 3.14.6
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -5,12 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.subscribeToBlockUpdates = void 0;
|
|
7
7
|
var _graphqlWs = require("graphql-ws");
|
|
8
|
+
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
8
9
|
var _utils = require("../../utils/utils");
|
|
9
10
|
var GRAPHQL_WS_ENDPOINT = '/gateway/api/graphql/subscriptions';
|
|
10
11
|
var blockServiceClient = null;
|
|
11
12
|
var getBlockServiceClient = function getBlockServiceClient() {
|
|
12
13
|
// Don't create client during SSR
|
|
13
|
-
if (
|
|
14
|
+
if ((0, _coreUtils.isSSR)()) {
|
|
14
15
|
return null;
|
|
15
16
|
}
|
|
16
17
|
if (!blockServiceClient) {
|
|
@@ -10,6 +10,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
12
|
var _react = require("react");
|
|
13
|
+
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
13
14
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
14
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _types = require("../common/types");
|
|
@@ -110,6 +111,11 @@ var useFetchSyncBlockData = exports.useFetchSyncBlockData = function useFetchSyn
|
|
|
110
111
|
}, _callee, null, [[2, 11]]);
|
|
111
112
|
})), [isLoading, localId, manager.referenceManager, resourceId, fireAnalyticsEvent]);
|
|
112
113
|
(0, _react.useEffect)(function () {
|
|
114
|
+
if ((0, _coreUtils.isSSR)()) {
|
|
115
|
+
// in SSR, we don't need to subscribe to updates,
|
|
116
|
+
// instead we rely on pre-fetched data ONLY, see initialization of syncBlockInstance above
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
113
119
|
var unsubscribe = manager.referenceManager.subscribeToSyncBlock(resourceId || '', localId || '', function (data) {
|
|
114
120
|
setFetchState({
|
|
115
121
|
syncBlockInstance: data,
|
|
@@ -11,6 +11,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
11
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
+
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
14
15
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
15
16
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
16
17
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
@@ -194,9 +195,16 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
194
195
|
}, {
|
|
195
196
|
key: "getInitialSyncBlockData",
|
|
196
197
|
value: function getInitialSyncBlockData(resourceId) {
|
|
197
|
-
var _this$
|
|
198
|
+
var _this$dataProvider2;
|
|
198
199
|
var syncBlockNode = (0, _utils.createSyncBlockNode)('', resourceId);
|
|
199
|
-
|
|
200
|
+
if ((0, _coreUtils.isSSR)() && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
201
|
+
var _this$dataProvider;
|
|
202
|
+
// In SSR, prefer data from data provider cache
|
|
203
|
+
// should not take from store manager cache as it may be in incomplete state
|
|
204
|
+
// will be unified to the same cache later.
|
|
205
|
+
return (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 || (_this$dataProvider = _this$dataProvider.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.data;
|
|
206
|
+
}
|
|
207
|
+
return this.getFromCache(resourceId) || ((_this$dataProvider2 = this.dataProvider) === null || _this$dataProvider2 === void 0 || (_this$dataProvider2 = _this$dataProvider2.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider2 === void 0 ? void 0 : _this$dataProvider2.data);
|
|
200
208
|
}
|
|
201
209
|
|
|
202
210
|
/**
|
|
@@ -301,13 +309,13 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
301
309
|
}, {
|
|
302
310
|
key: "setupGraphQLSubscription",
|
|
303
311
|
value: function setupGraphQLSubscription(resourceId) {
|
|
304
|
-
var _this$
|
|
312
|
+
var _this$dataProvider3,
|
|
305
313
|
_this3 = this;
|
|
306
314
|
// Don't set up duplicate subscriptions
|
|
307
315
|
if (this.graphqlSubscriptions.has(resourceId)) {
|
|
308
316
|
return;
|
|
309
317
|
}
|
|
310
|
-
if (!((_this$
|
|
318
|
+
if (!((_this$dataProvider3 = this.dataProvider) !== null && _this$dataProvider3 !== void 0 && _this$dataProvider3.subscribeToBlockUpdates)) {
|
|
311
319
|
return;
|
|
312
320
|
}
|
|
313
321
|
var unsubscribe = this.dataProvider.subscribeToBlockUpdates(resourceId, function (syncBlockInstance) {
|
|
@@ -709,7 +717,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
709
717
|
}, {
|
|
710
718
|
key: "subscribeToSyncBlock",
|
|
711
719
|
value: function subscribeToSyncBlock(resourceId, localId, callback) {
|
|
712
|
-
var _this$
|
|
720
|
+
var _this$dataProvider4,
|
|
721
|
+
_this$dataProvider5,
|
|
713
722
|
_this6 = this;
|
|
714
723
|
// Cancel any pending cache deletion for this resourceId.
|
|
715
724
|
// This handles the case where a block is moved - the old component unmounts
|
|
@@ -737,7 +746,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
737
746
|
|
|
738
747
|
// call the callback immediately if we have cached data
|
|
739
748
|
// prefer cache from store manager first, should update data provider to use the same cache
|
|
740
|
-
var cachedData =
|
|
749
|
+
var cachedData = (0, _coreUtils.isSSR)() && (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') // in SSR, prefer data provider cache
|
|
750
|
+
? ((_this$dataProvider4 = this.dataProvider) === null || _this$dataProvider4 === void 0 || (_this$dataProvider4 = _this$dataProvider4.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider4 === void 0 ? void 0 : _this$dataProvider4.data) || this.getFromCache(resourceId) : this.getFromCache(resourceId) || ((_this$dataProvider5 = this.dataProvider) === null || _this$dataProvider5 === void 0 || (_this$dataProvider5 = _this$dataProvider5.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider5 === void 0 ? void 0 : _this$dataProvider5.data);
|
|
741
751
|
if (cachedData) {
|
|
742
752
|
callback(cachedData);
|
|
743
753
|
} else {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createClient } from 'graphql-ws';
|
|
2
|
+
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
2
3
|
import { convertContentUpdatedAt } from '../../utils/utils';
|
|
3
4
|
const GRAPHQL_WS_ENDPOINT = '/gateway/api/graphql/subscriptions';
|
|
4
5
|
let blockServiceClient = null;
|
|
5
6
|
const getBlockServiceClient = () => {
|
|
6
7
|
// Don't create client during SSR
|
|
7
|
-
if (
|
|
8
|
+
if (isSSR()) {
|
|
8
9
|
return null;
|
|
9
10
|
}
|
|
10
11
|
if (!blockServiceClient) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
2
3
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
3
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { SyncBlockError } from '../common/types';
|
|
@@ -73,6 +74,11 @@ export const useFetchSyncBlockData = (manager, resourceId, localId, fireAnalytic
|
|
|
73
74
|
}));
|
|
74
75
|
}, [isLoading, localId, manager.referenceManager, resourceId, fireAnalyticsEvent]);
|
|
75
76
|
useEffect(() => {
|
|
77
|
+
if (isSSR()) {
|
|
78
|
+
// in SSR, we don't need to subscribe to updates,
|
|
79
|
+
// instead we rely on pre-fetched data ONLY, see initialization of syncBlockInstance above
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
76
82
|
const unsubscribe = manager.referenceManager.subscribeToSyncBlock(resourceId || '', localId || '', data => {
|
|
77
83
|
setFetchState({
|
|
78
84
|
syncBlockInstance: data,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
2
3
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
3
4
|
import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
4
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -151,9 +152,16 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
151
152
|
this.fireAnalyticsEvent = fireAnalyticsEvent;
|
|
152
153
|
}
|
|
153
154
|
getInitialSyncBlockData(resourceId) {
|
|
154
|
-
var _this$
|
|
155
|
+
var _this$dataProvider2, _this$dataProvider2$g;
|
|
155
156
|
const syncBlockNode = createSyncBlockNode('', resourceId);
|
|
156
|
-
|
|
157
|
+
if (isSSR() && fg('platform_synced_block_dogfooding')) {
|
|
158
|
+
var _this$dataProvider, _this$dataProvider$ge;
|
|
159
|
+
// In SSR, prefer data from data provider cache
|
|
160
|
+
// should not take from store manager cache as it may be in incomplete state
|
|
161
|
+
// will be unified to the same cache later.
|
|
162
|
+
return (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 ? void 0 : (_this$dataProvider$ge = _this$dataProvider.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider$ge === void 0 ? void 0 : _this$dataProvider$ge.data;
|
|
163
|
+
}
|
|
164
|
+
return this.getFromCache(resourceId) || ((_this$dataProvider2 = this.dataProvider) === null || _this$dataProvider2 === void 0 ? void 0 : (_this$dataProvider2$g = _this$dataProvider2.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider2$g === void 0 ? void 0 : _this$dataProvider2$g.data);
|
|
157
165
|
}
|
|
158
166
|
|
|
159
167
|
/**
|
|
@@ -196,12 +204,12 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
196
204
|
* @param resourceId - The resource ID of the block to subscribe to
|
|
197
205
|
*/
|
|
198
206
|
setupGraphQLSubscription(resourceId) {
|
|
199
|
-
var _this$
|
|
207
|
+
var _this$dataProvider3;
|
|
200
208
|
// Don't set up duplicate subscriptions
|
|
201
209
|
if (this.graphqlSubscriptions.has(resourceId)) {
|
|
202
210
|
return;
|
|
203
211
|
}
|
|
204
|
-
if (!((_this$
|
|
212
|
+
if (!((_this$dataProvider3 = this.dataProvider) !== null && _this$dataProvider3 !== void 0 && _this$dataProvider3.subscribeToBlockUpdates)) {
|
|
205
213
|
return;
|
|
206
214
|
}
|
|
207
215
|
const unsubscribe = this.dataProvider.subscribeToBlockUpdates(resourceId, syncBlockInstance => {
|
|
@@ -537,7 +545,7 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
537
545
|
this.providerFactories.delete(resourceId);
|
|
538
546
|
}
|
|
539
547
|
subscribeToSyncBlock(resourceId, localId, callback) {
|
|
540
|
-
var _this$
|
|
548
|
+
var _this$dataProvider4, _this$dataProvider4$g, _this$dataProvider5, _this$dataProvider5$g;
|
|
541
549
|
// Cancel any pending cache deletion for this resourceId.
|
|
542
550
|
// This handles the case where a block is moved - the old component unmounts
|
|
543
551
|
// (scheduling deletion) but the new component mounts and subscribes before
|
|
@@ -567,7 +575,8 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
567
575
|
|
|
568
576
|
// call the callback immediately if we have cached data
|
|
569
577
|
// prefer cache from store manager first, should update data provider to use the same cache
|
|
570
|
-
const cachedData =
|
|
578
|
+
const cachedData = isSSR() && fg('platform_synced_block_dogfooding') // in SSR, prefer data provider cache
|
|
579
|
+
? ((_this$dataProvider4 = this.dataProvider) === null || _this$dataProvider4 === void 0 ? void 0 : (_this$dataProvider4$g = _this$dataProvider4.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider4$g === void 0 ? void 0 : _this$dataProvider4$g.data) || this.getFromCache(resourceId) : this.getFromCache(resourceId) || ((_this$dataProvider5 = this.dataProvider) === null || _this$dataProvider5 === void 0 ? void 0 : (_this$dataProvider5$g = _this$dataProvider5.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider5$g === void 0 ? void 0 : _this$dataProvider5$g.data);
|
|
571
580
|
if (cachedData) {
|
|
572
581
|
callback(cachedData);
|
|
573
582
|
} else {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createClient } from 'graphql-ws';
|
|
2
|
+
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
2
3
|
import { convertContentUpdatedAt } from '../../utils/utils';
|
|
3
4
|
var GRAPHQL_WS_ENDPOINT = '/gateway/api/graphql/subscriptions';
|
|
4
5
|
var blockServiceClient = null;
|
|
5
6
|
var getBlockServiceClient = function getBlockServiceClient() {
|
|
6
7
|
// Don't create client during SSR
|
|
7
|
-
if (
|
|
8
|
+
if (isSSR()) {
|
|
8
9
|
return null;
|
|
9
10
|
}
|
|
10
11
|
if (!blockServiceClient) {
|
|
@@ -5,6 +5,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
8
9
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
9
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { SyncBlockError } from '../common/types';
|
|
@@ -103,6 +104,11 @@ export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resou
|
|
|
103
104
|
}, _callee, null, [[2, 11]]);
|
|
104
105
|
})), [isLoading, localId, manager.referenceManager, resourceId, fireAnalyticsEvent]);
|
|
105
106
|
useEffect(function () {
|
|
107
|
+
if (isSSR()) {
|
|
108
|
+
// in SSR, we don't need to subscribe to updates,
|
|
109
|
+
// instead we rely on pre-fetched data ONLY, see initialization of syncBlockInstance above
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
106
112
|
var unsubscribe = manager.referenceManager.subscribeToSyncBlock(resourceId || '', localId || '', function (data) {
|
|
107
113
|
setFetchState({
|
|
108
114
|
syncBlockInstance: data,
|
|
@@ -9,6 +9,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
9
9
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
10
10
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
11
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
|
+
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
12
13
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
13
14
|
import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
14
15
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -188,9 +189,16 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
188
189
|
}, {
|
|
189
190
|
key: "getInitialSyncBlockData",
|
|
190
191
|
value: function getInitialSyncBlockData(resourceId) {
|
|
191
|
-
var _this$
|
|
192
|
+
var _this$dataProvider2;
|
|
192
193
|
var syncBlockNode = createSyncBlockNode('', resourceId);
|
|
193
|
-
|
|
194
|
+
if (isSSR() && fg('platform_synced_block_dogfooding')) {
|
|
195
|
+
var _this$dataProvider;
|
|
196
|
+
// In SSR, prefer data from data provider cache
|
|
197
|
+
// should not take from store manager cache as it may be in incomplete state
|
|
198
|
+
// will be unified to the same cache later.
|
|
199
|
+
return (_this$dataProvider = this.dataProvider) === null || _this$dataProvider === void 0 || (_this$dataProvider = _this$dataProvider.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider === void 0 ? void 0 : _this$dataProvider.data;
|
|
200
|
+
}
|
|
201
|
+
return this.getFromCache(resourceId) || ((_this$dataProvider2 = this.dataProvider) === null || _this$dataProvider2 === void 0 || (_this$dataProvider2 = _this$dataProvider2.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider2 === void 0 ? void 0 : _this$dataProvider2.data);
|
|
194
202
|
}
|
|
195
203
|
|
|
196
204
|
/**
|
|
@@ -295,13 +303,13 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
295
303
|
}, {
|
|
296
304
|
key: "setupGraphQLSubscription",
|
|
297
305
|
value: function setupGraphQLSubscription(resourceId) {
|
|
298
|
-
var _this$
|
|
306
|
+
var _this$dataProvider3,
|
|
299
307
|
_this3 = this;
|
|
300
308
|
// Don't set up duplicate subscriptions
|
|
301
309
|
if (this.graphqlSubscriptions.has(resourceId)) {
|
|
302
310
|
return;
|
|
303
311
|
}
|
|
304
|
-
if (!((_this$
|
|
312
|
+
if (!((_this$dataProvider3 = this.dataProvider) !== null && _this$dataProvider3 !== void 0 && _this$dataProvider3.subscribeToBlockUpdates)) {
|
|
305
313
|
return;
|
|
306
314
|
}
|
|
307
315
|
var unsubscribe = this.dataProvider.subscribeToBlockUpdates(resourceId, function (syncBlockInstance) {
|
|
@@ -703,7 +711,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
703
711
|
}, {
|
|
704
712
|
key: "subscribeToSyncBlock",
|
|
705
713
|
value: function subscribeToSyncBlock(resourceId, localId, callback) {
|
|
706
|
-
var _this$
|
|
714
|
+
var _this$dataProvider4,
|
|
715
|
+
_this$dataProvider5,
|
|
707
716
|
_this6 = this;
|
|
708
717
|
// Cancel any pending cache deletion for this resourceId.
|
|
709
718
|
// This handles the case where a block is moved - the old component unmounts
|
|
@@ -731,7 +740,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
731
740
|
|
|
732
741
|
// call the callback immediately if we have cached data
|
|
733
742
|
// prefer cache from store manager first, should update data provider to use the same cache
|
|
734
|
-
var cachedData =
|
|
743
|
+
var cachedData = isSSR() && fg('platform_synced_block_dogfooding') // in SSR, prefer data provider cache
|
|
744
|
+
? ((_this$dataProvider4 = this.dataProvider) === null || _this$dataProvider4 === void 0 || (_this$dataProvider4 = _this$dataProvider4.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider4 === void 0 ? void 0 : _this$dataProvider4.data) || this.getFromCache(resourceId) : this.getFromCache(resourceId) || ((_this$dataProvider5 = this.dataProvider) === null || _this$dataProvider5 === void 0 || (_this$dataProvider5 = _this$dataProvider5.getNodeDataFromCache(syncBlockNode)) === null || _this$dataProvider5 === void 0 ? void 0 : _this$dataProvider5.data);
|
|
735
745
|
if (cachedData) {
|
|
736
746
|
callback(cachedData);
|
|
737
747
|
} else {
|
package/package.json
CHANGED