@atlaskit/editor-plugin-engagement-platform 2.1.1 → 2.2.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 +21 -0
- package/dist/cjs/actions/startMessage.js +55 -55
- package/dist/cjs/actions/stopMessage.js +57 -55
- package/dist/cjs/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPlugin.js +62 -14
- package/dist/cjs/pmPlugins/engagementPlatformPmPlugin/{commands/setMessageState.js → engagementPlatformPmPluginCommand.js} +10 -7
- package/dist/es2019/actions/startMessage.js +41 -15
- package/dist/es2019/actions/stopMessage.js +40 -12
- package/dist/es2019/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPlugin.js +61 -13
- package/dist/es2019/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginCommand.js +14 -0
- package/dist/esm/actions/startMessage.js +55 -54
- package/dist/esm/actions/stopMessage.js +57 -54
- package/dist/esm/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPlugin.js +62 -14
- package/dist/esm/pmPlugins/engagementPlatformPmPlugin/{commands/setMessageState.js → engagementPlatformPmPluginCommand.js} +9 -6
- package/dist/types/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginCommand.d.ts +3 -0
- package/dist/types/pmPlugins/engagementPlatformPmPlugin/types.d.ts +38 -8
- package/dist/types-ts4.5/pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginCommand.d.ts +3 -0
- package/dist/types-ts4.5/pmPlugins/engagementPlatformPmPlugin/types.d.ts +38 -8
- package/package.json +3 -3
- package/dist/es2019/pmPlugins/engagementPlatformPmPlugin/commands/setMessageState.js +0 -14
- package/dist/types/pmPlugins/engagementPlatformPmPlugin/commands/setMessageState.d.ts +0 -3
- package/dist/types-ts4.5/pmPlugins/engagementPlatformPmPlugin/commands/setMessageState.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-engagement-platform
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#154829](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/154829)
|
|
8
|
+
[`0646280e9ab18`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0646280e9ab18) -
|
|
9
|
+
[EDF-1176](https://product-fabric.atlassian.net/browse/EDF-1176) - add pulse EP effect to AI
|
|
10
|
+
button in Editor floating toolbar
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 2.1.2
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#155735](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/155735)
|
|
21
|
+
[`1beeeda29023a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1beeeda29023a) -
|
|
22
|
+
Upgrades editor packages to react 18
|
|
23
|
+
|
|
3
24
|
## 2.1.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -1,66 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.startMessage = startMessage;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
-
var
|
|
8
|
+
var _engagementPlatformPmPluginCommand = require("../pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginCommand");
|
|
12
9
|
function startMessage(api, coordinationClient) {
|
|
13
|
-
return
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
50
|
-
attributes: {
|
|
51
|
-
error: _context.t0 instanceof Error ? _context.t0.message : "".concat(_context.t0),
|
|
52
|
-
errorStack: _context.t0 instanceof Error ? _context.t0.stack : undefined
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return _context.abrupt("return", false);
|
|
56
|
-
case 18:
|
|
57
|
-
case "end":
|
|
58
|
-
return _context.stop();
|
|
10
|
+
return function (messageId, variationId) {
|
|
11
|
+
var _api$engagementPlatfo, _api$engagementPlatfo2, _api$engagementPlatfo3, _api$engagementPlatfo4;
|
|
12
|
+
if (!api) {
|
|
13
|
+
return Promise.resolve(false);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// If the message is already started (even with `false` state), return the state
|
|
17
|
+
var messageStates = (_api$engagementPlatfo = (_api$engagementPlatfo2 = api.engagementPlatform.sharedState.currentState()) === null || _api$engagementPlatfo2 === void 0 ? void 0 : _api$engagementPlatfo2.messageStates) !== null && _api$engagementPlatfo !== void 0 ? _api$engagementPlatfo : {};
|
|
18
|
+
var messageState = messageStates[messageId];
|
|
19
|
+
if (messageState !== undefined) {
|
|
20
|
+
return Promise.resolve(messageState);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// If there is already a start message promise, return it to prevent multiple start requests
|
|
24
|
+
var startMessagePromises = (_api$engagementPlatfo3 = (_api$engagementPlatfo4 = api.engagementPlatform.sharedState.currentState()) === null || _api$engagementPlatfo4 === void 0 ? void 0 : _api$engagementPlatfo4.startMessagePromises) !== null && _api$engagementPlatfo3 !== void 0 ? _api$engagementPlatfo3 : {};
|
|
25
|
+
var startMessagePromise = startMessagePromises[messageId];
|
|
26
|
+
if (startMessagePromise) {
|
|
27
|
+
return startMessagePromise;
|
|
28
|
+
}
|
|
29
|
+
var newStartedMessagePromise = coordinationClient.start(messageId, variationId).then(function (isStarted) {
|
|
30
|
+
// Update the message state in the shared state
|
|
31
|
+
api.core.actions.execute((0, _engagementPlatformPmPluginCommand.engagementPlatformPmPluginCommand)({
|
|
32
|
+
type: 'setMessageState',
|
|
33
|
+
messageId: messageId,
|
|
34
|
+
state: isStarted
|
|
35
|
+
}));
|
|
36
|
+
return isStarted;
|
|
37
|
+
}).catch(function (error) {
|
|
38
|
+
var _api$analytics;
|
|
39
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
40
|
+
action: _analytics.ACTION.ERRORED,
|
|
41
|
+
actionSubject: _analytics.ACTION_SUBJECT.ENGAGEMENT_PLATFORM,
|
|
42
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
43
|
+
attributes: {
|
|
44
|
+
error: error instanceof Error ? error.message : "".concat(error),
|
|
45
|
+
errorStack: error instanceof Error ? error.stack : undefined
|
|
59
46
|
}
|
|
60
|
-
}
|
|
47
|
+
});
|
|
48
|
+
return false;
|
|
49
|
+
}).finally(function () {
|
|
50
|
+
// Remove the promise from the state after it has been resolved
|
|
51
|
+
api.core.actions.execute((0, _engagementPlatformPmPluginCommand.engagementPlatformPmPluginCommand)({
|
|
52
|
+
type: 'setStartMessagePromise',
|
|
53
|
+
messageId: messageId,
|
|
54
|
+
promise: undefined
|
|
55
|
+
}));
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Store the promise in the shared state to prevent multiple start requests for the same message
|
|
59
|
+
api.core.actions.execute((0, _engagementPlatformPmPluginCommand.engagementPlatformPmPluginCommand)({
|
|
60
|
+
type: 'setStartMessagePromise',
|
|
61
|
+
messageId: messageId,
|
|
62
|
+
promise: newStartedMessagePromise
|
|
61
63
|
}));
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
};
|
|
65
|
-
}();
|
|
64
|
+
return newStartedMessagePromise;
|
|
65
|
+
};
|
|
66
66
|
}
|
|
@@ -1,66 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.stopMessage = stopMessage;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
-
var
|
|
8
|
+
var _engagementPlatformPmPluginCommand = require("../pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginCommand");
|
|
12
9
|
function stopMessage(api, coordinationClient) {
|
|
13
|
-
return
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
error: _context.t0 instanceof Error ? _context.t0.message : "".concat(_context.t0),
|
|
52
|
-
errorStack: _context.t0 instanceof Error ? _context.t0.stack : undefined
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return _context.abrupt("return", false);
|
|
56
|
-
case 18:
|
|
57
|
-
case "end":
|
|
58
|
-
return _context.stop();
|
|
10
|
+
return function (messageId) {
|
|
11
|
+
var _api$engagementPlatfo, _api$engagementPlatfo2, _api$engagementPlatfo3, _api$engagementPlatfo4;
|
|
12
|
+
if (!api) {
|
|
13
|
+
return Promise.resolve(false);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// If the message is already stopped, return `true`
|
|
17
|
+
var messageStates = (_api$engagementPlatfo = (_api$engagementPlatfo2 = api.engagementPlatform.sharedState.currentState()) === null || _api$engagementPlatfo2 === void 0 ? void 0 : _api$engagementPlatfo2.messageStates) !== null && _api$engagementPlatfo !== void 0 ? _api$engagementPlatfo : {};
|
|
18
|
+
var isActive = messageStates[messageId];
|
|
19
|
+
if (isActive === false) {
|
|
20
|
+
return Promise.resolve(true);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// If there is already a stop message promise, return it to prevent multiple stop requests
|
|
24
|
+
var stopMessagePromises = (_api$engagementPlatfo3 = (_api$engagementPlatfo4 = api.engagementPlatform.sharedState.currentState()) === null || _api$engagementPlatfo4 === void 0 ? void 0 : _api$engagementPlatfo4.stopMessagePromises) !== null && _api$engagementPlatfo3 !== void 0 ? _api$engagementPlatfo3 : {};
|
|
25
|
+
var stopMessagePromise = stopMessagePromises[messageId];
|
|
26
|
+
if (stopMessagePromise) {
|
|
27
|
+
return stopMessagePromise;
|
|
28
|
+
}
|
|
29
|
+
var newStopMessagePromise = coordinationClient.stop(messageId).then(function (isStopped) {
|
|
30
|
+
// Update the message state in the shared state
|
|
31
|
+
if (isStopped) {
|
|
32
|
+
api.core.actions.execute((0, _engagementPlatformPmPluginCommand.engagementPlatformPmPluginCommand)({
|
|
33
|
+
type: 'setMessageState',
|
|
34
|
+
messageId: messageId,
|
|
35
|
+
state: false
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
return isStopped;
|
|
39
|
+
}).catch(function (error) {
|
|
40
|
+
var _api$analytics;
|
|
41
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
42
|
+
action: _analytics.ACTION.ERRORED,
|
|
43
|
+
actionSubject: _analytics.ACTION_SUBJECT.ENGAGEMENT_PLATFORM,
|
|
44
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
45
|
+
attributes: {
|
|
46
|
+
error: error instanceof Error ? error.message : "".concat(error),
|
|
47
|
+
errorStack: error instanceof Error ? error.stack : undefined
|
|
59
48
|
}
|
|
60
|
-
}
|
|
49
|
+
});
|
|
50
|
+
return false;
|
|
51
|
+
}).finally(function () {
|
|
52
|
+
// Remove the promise from the state after it has been resolved
|
|
53
|
+
api.core.actions.execute((0, _engagementPlatformPmPluginCommand.engagementPlatformPmPluginCommand)({
|
|
54
|
+
type: 'setStopMessagePromise',
|
|
55
|
+
messageId: messageId,
|
|
56
|
+
promise: undefined
|
|
57
|
+
}));
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Store the promise in the shared state to prevent multiple stop requests for the same message
|
|
61
|
+
api.core.actions.execute((0, _engagementPlatformPmPluginCommand.engagementPlatformPmPluginCommand)({
|
|
62
|
+
type: 'setStopMessagePromise',
|
|
63
|
+
messageId: messageId,
|
|
64
|
+
promise: newStopMessagePromise
|
|
61
65
|
}));
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
};
|
|
65
|
-
}();
|
|
66
|
+
return newStopMessagePromise;
|
|
67
|
+
};
|
|
66
68
|
}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.engagementPlatformPmPlugin = void 0;
|
|
8
|
-
var
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
12
|
var _engagementPlatformPmPluginKey = require("./engagementPlatformPmPluginKey");
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
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; } } }; }
|
|
16
|
+
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; } }
|
|
17
|
+
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
18
|
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; }
|
|
13
19
|
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) { (0, _defineProperty2.default)(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; }
|
|
14
20
|
var engagementPlatformPmPlugin = exports.engagementPlatformPmPlugin = function engagementPlatformPmPlugin(pluginConfig) {
|
|
@@ -18,6 +24,8 @@ var engagementPlatformPmPlugin = exports.engagementPlatformPmPlugin = function e
|
|
|
18
24
|
init: function init() {
|
|
19
25
|
return {
|
|
20
26
|
messageStates: {},
|
|
27
|
+
startMessagePromises: {},
|
|
28
|
+
stopMessagePromises: {},
|
|
21
29
|
epComponents: pluginConfig.epComponents,
|
|
22
30
|
epHooks: pluginConfig.epHooks,
|
|
23
31
|
coordinationClient: pluginConfig.coordinationClient
|
|
@@ -28,20 +36,60 @@ var engagementPlatformPmPlugin = exports.engagementPlatformPmPlugin = function e
|
|
|
28
36
|
if (!meta) {
|
|
29
37
|
return pluginState;
|
|
30
38
|
}
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
var state = _objectSpread({}, pluginState);
|
|
40
|
+
var _iterator = _createForOfIteratorHelper(meta.commands),
|
|
41
|
+
_step;
|
|
42
|
+
try {
|
|
43
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
44
|
+
var command = _step.value;
|
|
45
|
+
switch (command.type) {
|
|
46
|
+
case 'setMessageState':
|
|
47
|
+
state = _objectSpread(_objectSpread({}, state), {}, {
|
|
48
|
+
messageStates: _objectSpread(_objectSpread({}, state.messageStates), {}, (0, _defineProperty2.default)({}, command.messageId, command.state))
|
|
49
|
+
});
|
|
50
|
+
break;
|
|
51
|
+
case 'setStartMessagePromise':
|
|
52
|
+
if (command.promise !== undefined) {
|
|
53
|
+
state = _objectSpread(_objectSpread({}, state), {}, {
|
|
54
|
+
startMessagePromises: _objectSpread(_objectSpread({}, state.startMessagePromises), {}, (0, _defineProperty2.default)({}, command.messageId, command.promise))
|
|
55
|
+
});
|
|
56
|
+
break;
|
|
57
|
+
} else {
|
|
58
|
+
// If the promise is undefined, remove it from the state
|
|
59
|
+
var _state$startMessagePr = state.startMessagePromises,
|
|
60
|
+
_command$messageId = command.messageId,
|
|
61
|
+
_ = _state$startMessagePr[_command$messageId],
|
|
62
|
+
startMessagePromises = (0, _objectWithoutProperties2.default)(_state$startMessagePr, [_command$messageId].map(_toPropertyKey));
|
|
63
|
+
state = _objectSpread(_objectSpread({}, state), {}, {
|
|
64
|
+
startMessagePromises: startMessagePromises
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
case 'setStopMessagePromise':
|
|
69
|
+
if (command.promise !== undefined) {
|
|
70
|
+
state = _objectSpread(_objectSpread({}, state), {}, {
|
|
71
|
+
stopMessagePromises: _objectSpread(_objectSpread({}, state.stopMessagePromises), {}, (0, _defineProperty2.default)({}, command.messageId, command.promise))
|
|
72
|
+
});
|
|
73
|
+
break;
|
|
74
|
+
} else {
|
|
75
|
+
// If the promise is undefined, remove it from the state
|
|
76
|
+
var _state$stopMessagePro = state.stopMessagePromises,
|
|
77
|
+
_command$messageId2 = command.messageId,
|
|
78
|
+
_2 = _state$stopMessagePro[_command$messageId2],
|
|
79
|
+
stopMessagePromises = (0, _objectWithoutProperties2.default)(_state$stopMessagePro, [_command$messageId2].map(_toPropertyKey));
|
|
80
|
+
state = _objectSpread(_objectSpread({}, state), {}, {
|
|
81
|
+
stopMessagePromises: stopMessagePromises
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
42
86
|
}
|
|
43
|
-
})
|
|
44
|
-
|
|
87
|
+
} catch (err) {
|
|
88
|
+
_iterator.e(err);
|
|
89
|
+
} finally {
|
|
90
|
+
_iterator.f();
|
|
91
|
+
}
|
|
92
|
+
return state;
|
|
45
93
|
}
|
|
46
94
|
}
|
|
47
95
|
});
|
|
@@ -4,19 +4,22 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.engagementPlatformPmPluginCommand = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _engagementPlatformPmPluginKey = require("
|
|
10
|
+
var _engagementPlatformPmPluginKey = require("./engagementPlatformPmPluginKey");
|
|
10
11
|
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; }
|
|
11
12
|
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) { (0, _defineProperty2.default)(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; }
|
|
12
|
-
|
|
13
|
-
var setMessageState = exports.setMessageState = function setMessageState(messageIs, state) {
|
|
13
|
+
var engagementPlatformPmPluginCommand = exports.engagementPlatformPmPluginCommand = function engagementPlatformPmPluginCommand(command) {
|
|
14
14
|
return function (_ref) {
|
|
15
15
|
var _tr$getMeta;
|
|
16
16
|
var tr = _ref.tr;
|
|
17
|
-
var
|
|
18
|
-
|
|
17
|
+
var currentMeta = (_tr$getMeta = tr.getMeta(_engagementPlatformPmPluginKey.engagementPlatformPmPluginKey)) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : {
|
|
18
|
+
commands: []
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
var newMeta = _objectSpread(_objectSpread({}, currentMeta), {}, {
|
|
21
|
+
commands: [].concat((0, _toConsumableArray2.default)(currentMeta.commands), [command])
|
|
22
|
+
});
|
|
23
|
+
return tr.setMeta(_engagementPlatformPmPluginKey.engagementPlatformPmPluginKey, newMeta);
|
|
21
24
|
};
|
|
22
25
|
};
|
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import {
|
|
2
|
+
import { engagementPlatformPmPluginCommand } from '../pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginCommand';
|
|
3
3
|
export function startMessage(api, coordinationClient) {
|
|
4
|
-
return
|
|
5
|
-
var _api$engagementPlatfo, _api$engagementPlatfo2;
|
|
4
|
+
return (messageId, variationId) => {
|
|
5
|
+
var _api$engagementPlatfo, _api$engagementPlatfo2, _api$engagementPlatfo3, _api$engagementPlatfo4;
|
|
6
6
|
if (!api) {
|
|
7
|
-
return false;
|
|
7
|
+
return Promise.resolve(false);
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
// If the message is already started (even with `false` state), return the state
|
|
9
11
|
const messageStates = (_api$engagementPlatfo = (_api$engagementPlatfo2 = api.engagementPlatform.sharedState.currentState()) === null || _api$engagementPlatfo2 === void 0 ? void 0 : _api$engagementPlatfo2.messageStates) !== null && _api$engagementPlatfo !== void 0 ? _api$engagementPlatfo : {};
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
12
|
+
const messageState = messageStates[messageId];
|
|
13
|
+
if (messageState !== undefined) {
|
|
14
|
+
return Promise.resolve(messageState);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// If there is already a start message promise, return it to prevent multiple start requests
|
|
18
|
+
const startMessagePromises = (_api$engagementPlatfo3 = (_api$engagementPlatfo4 = api.engagementPlatform.sharedState.currentState()) === null || _api$engagementPlatfo4 === void 0 ? void 0 : _api$engagementPlatfo4.startMessagePromises) !== null && _api$engagementPlatfo3 !== void 0 ? _api$engagementPlatfo3 : {};
|
|
19
|
+
const startMessagePromise = startMessagePromises[messageId];
|
|
20
|
+
if (startMessagePromise) {
|
|
21
|
+
return startMessagePromise;
|
|
13
22
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
const newStartedMessagePromise = coordinationClient.start(messageId, variationId).then(isStarted => {
|
|
24
|
+
// Update the message state in the shared state
|
|
25
|
+
api.core.actions.execute(engagementPlatformPmPluginCommand({
|
|
26
|
+
type: 'setMessageState',
|
|
27
|
+
messageId,
|
|
28
|
+
state: isStarted
|
|
29
|
+
}));
|
|
19
30
|
return isStarted;
|
|
20
|
-
}
|
|
31
|
+
}).catch(error => {
|
|
21
32
|
var _api$analytics;
|
|
22
|
-
(_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent({
|
|
33
|
+
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent({
|
|
23
34
|
action: ACTION.ERRORED,
|
|
24
35
|
actionSubject: ACTION_SUBJECT.ENGAGEMENT_PLATFORM,
|
|
25
36
|
eventType: EVENT_TYPE.OPERATIONAL,
|
|
@@ -29,6 +40,21 @@ export function startMessage(api, coordinationClient) {
|
|
|
29
40
|
}
|
|
30
41
|
});
|
|
31
42
|
return false;
|
|
32
|
-
}
|
|
43
|
+
}).finally(() => {
|
|
44
|
+
// Remove the promise from the state after it has been resolved
|
|
45
|
+
api.core.actions.execute(engagementPlatformPmPluginCommand({
|
|
46
|
+
type: 'setStartMessagePromise',
|
|
47
|
+
messageId,
|
|
48
|
+
promise: undefined
|
|
49
|
+
}));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Store the promise in the shared state to prevent multiple start requests for the same message
|
|
53
|
+
api.core.actions.execute(engagementPlatformPmPluginCommand({
|
|
54
|
+
type: 'setStartMessagePromise',
|
|
55
|
+
messageId,
|
|
56
|
+
promise: newStartedMessagePromise
|
|
57
|
+
}));
|
|
58
|
+
return newStartedMessagePromise;
|
|
33
59
|
};
|
|
34
60
|
}
|
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import {
|
|
2
|
+
import { engagementPlatformPmPluginCommand } from '../pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginCommand';
|
|
3
3
|
export function stopMessage(api, coordinationClient) {
|
|
4
|
-
return
|
|
5
|
-
var _api$engagementPlatfo, _api$engagementPlatfo2;
|
|
4
|
+
return messageId => {
|
|
5
|
+
var _api$engagementPlatfo, _api$engagementPlatfo2, _api$engagementPlatfo3, _api$engagementPlatfo4;
|
|
6
6
|
if (!api) {
|
|
7
|
-
return false;
|
|
7
|
+
return Promise.resolve(false);
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
// If the message is already stopped, return `true`
|
|
9
11
|
const messageStates = (_api$engagementPlatfo = (_api$engagementPlatfo2 = api.engagementPlatform.sharedState.currentState()) === null || _api$engagementPlatfo2 === void 0 ? void 0 : _api$engagementPlatfo2.messageStates) !== null && _api$engagementPlatfo !== void 0 ? _api$engagementPlatfo : {};
|
|
10
12
|
const isActive = messageStates[messageId];
|
|
11
|
-
if (
|
|
12
|
-
return true;
|
|
13
|
+
if (isActive === false) {
|
|
14
|
+
return Promise.resolve(true);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// If there is already a stop message promise, return it to prevent multiple stop requests
|
|
18
|
+
const stopMessagePromises = (_api$engagementPlatfo3 = (_api$engagementPlatfo4 = api.engagementPlatform.sharedState.currentState()) === null || _api$engagementPlatfo4 === void 0 ? void 0 : _api$engagementPlatfo4.stopMessagePromises) !== null && _api$engagementPlatfo3 !== void 0 ? _api$engagementPlatfo3 : {};
|
|
19
|
+
const stopMessagePromise = stopMessagePromises[messageId];
|
|
20
|
+
if (stopMessagePromise) {
|
|
21
|
+
return stopMessagePromise;
|
|
13
22
|
}
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
const newStopMessagePromise = coordinationClient.stop(messageId).then(isStopped => {
|
|
24
|
+
// Update the message state in the shared state
|
|
16
25
|
if (isStopped) {
|
|
17
|
-
api.core.actions.execute(
|
|
26
|
+
api.core.actions.execute(engagementPlatformPmPluginCommand({
|
|
27
|
+
type: 'setMessageState',
|
|
28
|
+
messageId,
|
|
29
|
+
state: false
|
|
30
|
+
}));
|
|
18
31
|
}
|
|
19
32
|
return isStopped;
|
|
20
|
-
}
|
|
33
|
+
}).catch(error => {
|
|
21
34
|
var _api$analytics;
|
|
22
|
-
(_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent({
|
|
35
|
+
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent({
|
|
23
36
|
action: ACTION.ERRORED,
|
|
24
37
|
actionSubject: ACTION_SUBJECT.ENGAGEMENT_PLATFORM,
|
|
25
38
|
eventType: EVENT_TYPE.OPERATIONAL,
|
|
@@ -29,6 +42,21 @@ export function stopMessage(api, coordinationClient) {
|
|
|
29
42
|
}
|
|
30
43
|
});
|
|
31
44
|
return false;
|
|
32
|
-
}
|
|
45
|
+
}).finally(() => {
|
|
46
|
+
// Remove the promise from the state after it has been resolved
|
|
47
|
+
api.core.actions.execute(engagementPlatformPmPluginCommand({
|
|
48
|
+
type: 'setStopMessagePromise',
|
|
49
|
+
messageId,
|
|
50
|
+
promise: undefined
|
|
51
|
+
}));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Store the promise in the shared state to prevent multiple stop requests for the same message
|
|
55
|
+
api.core.actions.execute(engagementPlatformPmPluginCommand({
|
|
56
|
+
type: 'setStopMessagePromise',
|
|
57
|
+
messageId,
|
|
58
|
+
promise: newStopMessagePromise
|
|
59
|
+
}));
|
|
60
|
+
return newStopMessagePromise;
|
|
33
61
|
};
|
|
34
62
|
}
|
|
@@ -7,6 +7,8 @@ export const engagementPlatformPmPlugin = pluginConfig => {
|
|
|
7
7
|
init: () => {
|
|
8
8
|
return {
|
|
9
9
|
messageStates: {},
|
|
10
|
+
startMessagePromises: {},
|
|
11
|
+
stopMessagePromises: {},
|
|
10
12
|
epComponents: pluginConfig.epComponents,
|
|
11
13
|
epHooks: pluginConfig.epHooks,
|
|
12
14
|
coordinationClient: pluginConfig.coordinationClient
|
|
@@ -17,21 +19,67 @@ export const engagementPlatformPmPlugin = pluginConfig => {
|
|
|
17
19
|
if (!meta) {
|
|
18
20
|
return pluginState;
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
...pluginState
|
|
22
|
-
messageStates: {
|
|
23
|
-
...pluginState.messageStates,
|
|
24
|
-
...meta.newMessageStates
|
|
25
|
-
}
|
|
22
|
+
let state = {
|
|
23
|
+
...pluginState
|
|
26
24
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
for (const command of meta.commands) {
|
|
26
|
+
switch (command.type) {
|
|
27
|
+
case 'setMessageState':
|
|
28
|
+
state = {
|
|
29
|
+
...state,
|
|
30
|
+
messageStates: {
|
|
31
|
+
...state.messageStates,
|
|
32
|
+
[command.messageId]: command.state
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
break;
|
|
36
|
+
case 'setStartMessagePromise':
|
|
37
|
+
if (command.promise !== undefined) {
|
|
38
|
+
state = {
|
|
39
|
+
...state,
|
|
40
|
+
startMessagePromises: {
|
|
41
|
+
...state.startMessagePromises,
|
|
42
|
+
[command.messageId]: command.promise
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
break;
|
|
46
|
+
} else {
|
|
47
|
+
// If the promise is undefined, remove it from the state
|
|
48
|
+
const {
|
|
49
|
+
[command.messageId]: _,
|
|
50
|
+
...startMessagePromises
|
|
51
|
+
} = state.startMessagePromises;
|
|
52
|
+
state = {
|
|
53
|
+
...state,
|
|
54
|
+
startMessagePromises
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
case 'setStopMessagePromise':
|
|
59
|
+
if (command.promise !== undefined) {
|
|
60
|
+
state = {
|
|
61
|
+
...state,
|
|
62
|
+
stopMessagePromises: {
|
|
63
|
+
...state.stopMessagePromises,
|
|
64
|
+
[command.messageId]: command.promise
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
break;
|
|
68
|
+
} else {
|
|
69
|
+
// If the promise is undefined, remove it from the state
|
|
70
|
+
const {
|
|
71
|
+
[command.messageId]: _,
|
|
72
|
+
...stopMessagePromises
|
|
73
|
+
} = state.stopMessagePromises;
|
|
74
|
+
state = {
|
|
75
|
+
...state,
|
|
76
|
+
stopMessagePromises
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
32
80
|
}
|
|
33
|
-
}
|
|
34
|
-
return
|
|
81
|
+
}
|
|
82
|
+
return state;
|
|
35
83
|
}
|
|
36
84
|
}
|
|
37
85
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { engagementPlatformPmPluginKey } from './engagementPlatformPmPluginKey';
|
|
2
|
+
export const engagementPlatformPmPluginCommand = command => ({
|
|
3
|
+
tr
|
|
4
|
+
}) => {
|
|
5
|
+
var _tr$getMeta;
|
|
6
|
+
const currentMeta = (_tr$getMeta = tr.getMeta(engagementPlatformPmPluginKey)) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : {
|
|
7
|
+
commands: []
|
|
8
|
+
};
|
|
9
|
+
const newMeta = {
|
|
10
|
+
...currentMeta,
|
|
11
|
+
commands: [...currentMeta.commands, command]
|
|
12
|
+
};
|
|
13
|
+
return tr.setMeta(engagementPlatformPmPluginKey, newMeta);
|
|
14
|
+
};
|
|
@@ -1,59 +1,60 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
1
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import {
|
|
2
|
+
import { engagementPlatformPmPluginCommand } from '../pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginCommand';
|
|
5
3
|
export function startMessage(api, coordinationClient) {
|
|
6
|
-
return
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
43
|
-
attributes: {
|
|
44
|
-
error: _context.t0 instanceof Error ? _context.t0.message : "".concat(_context.t0),
|
|
45
|
-
errorStack: _context.t0 instanceof Error ? _context.t0.stack : undefined
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
return _context.abrupt("return", false);
|
|
49
|
-
case 18:
|
|
50
|
-
case "end":
|
|
51
|
-
return _context.stop();
|
|
4
|
+
return function (messageId, variationId) {
|
|
5
|
+
var _api$engagementPlatfo, _api$engagementPlatfo2, _api$engagementPlatfo3, _api$engagementPlatfo4;
|
|
6
|
+
if (!api) {
|
|
7
|
+
return Promise.resolve(false);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// If the message is already started (even with `false` state), return the state
|
|
11
|
+
var messageStates = (_api$engagementPlatfo = (_api$engagementPlatfo2 = api.engagementPlatform.sharedState.currentState()) === null || _api$engagementPlatfo2 === void 0 ? void 0 : _api$engagementPlatfo2.messageStates) !== null && _api$engagementPlatfo !== void 0 ? _api$engagementPlatfo : {};
|
|
12
|
+
var messageState = messageStates[messageId];
|
|
13
|
+
if (messageState !== undefined) {
|
|
14
|
+
return Promise.resolve(messageState);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// If there is already a start message promise, return it to prevent multiple start requests
|
|
18
|
+
var startMessagePromises = (_api$engagementPlatfo3 = (_api$engagementPlatfo4 = api.engagementPlatform.sharedState.currentState()) === null || _api$engagementPlatfo4 === void 0 ? void 0 : _api$engagementPlatfo4.startMessagePromises) !== null && _api$engagementPlatfo3 !== void 0 ? _api$engagementPlatfo3 : {};
|
|
19
|
+
var startMessagePromise = startMessagePromises[messageId];
|
|
20
|
+
if (startMessagePromise) {
|
|
21
|
+
return startMessagePromise;
|
|
22
|
+
}
|
|
23
|
+
var newStartedMessagePromise = coordinationClient.start(messageId, variationId).then(function (isStarted) {
|
|
24
|
+
// Update the message state in the shared state
|
|
25
|
+
api.core.actions.execute(engagementPlatformPmPluginCommand({
|
|
26
|
+
type: 'setMessageState',
|
|
27
|
+
messageId: messageId,
|
|
28
|
+
state: isStarted
|
|
29
|
+
}));
|
|
30
|
+
return isStarted;
|
|
31
|
+
}).catch(function (error) {
|
|
32
|
+
var _api$analytics;
|
|
33
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
34
|
+
action: ACTION.ERRORED,
|
|
35
|
+
actionSubject: ACTION_SUBJECT.ENGAGEMENT_PLATFORM,
|
|
36
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
37
|
+
attributes: {
|
|
38
|
+
error: error instanceof Error ? error.message : "".concat(error),
|
|
39
|
+
errorStack: error instanceof Error ? error.stack : undefined
|
|
52
40
|
}
|
|
53
|
-
}
|
|
41
|
+
});
|
|
42
|
+
return false;
|
|
43
|
+
}).finally(function () {
|
|
44
|
+
// Remove the promise from the state after it has been resolved
|
|
45
|
+
api.core.actions.execute(engagementPlatformPmPluginCommand({
|
|
46
|
+
type: 'setStartMessagePromise',
|
|
47
|
+
messageId: messageId,
|
|
48
|
+
promise: undefined
|
|
49
|
+
}));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Store the promise in the shared state to prevent multiple start requests for the same message
|
|
53
|
+
api.core.actions.execute(engagementPlatformPmPluginCommand({
|
|
54
|
+
type: 'setStartMessagePromise',
|
|
55
|
+
messageId: messageId,
|
|
56
|
+
promise: newStartedMessagePromise
|
|
54
57
|
}));
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
}();
|
|
58
|
+
return newStartedMessagePromise;
|
|
59
|
+
};
|
|
59
60
|
}
|
|
@@ -1,59 +1,62 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
1
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import {
|
|
2
|
+
import { engagementPlatformPmPluginCommand } from '../pmPlugins/engagementPlatformPmPlugin/engagementPlatformPmPluginCommand';
|
|
5
3
|
export function stopMessage(api, coordinationClient) {
|
|
6
|
-
return
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
error: _context.t0 instanceof Error ? _context.t0.message : "".concat(_context.t0),
|
|
45
|
-
errorStack: _context.t0 instanceof Error ? _context.t0.stack : undefined
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
return _context.abrupt("return", false);
|
|
49
|
-
case 18:
|
|
50
|
-
case "end":
|
|
51
|
-
return _context.stop();
|
|
4
|
+
return function (messageId) {
|
|
5
|
+
var _api$engagementPlatfo, _api$engagementPlatfo2, _api$engagementPlatfo3, _api$engagementPlatfo4;
|
|
6
|
+
if (!api) {
|
|
7
|
+
return Promise.resolve(false);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// If the message is already stopped, return `true`
|
|
11
|
+
var messageStates = (_api$engagementPlatfo = (_api$engagementPlatfo2 = api.engagementPlatform.sharedState.currentState()) === null || _api$engagementPlatfo2 === void 0 ? void 0 : _api$engagementPlatfo2.messageStates) !== null && _api$engagementPlatfo !== void 0 ? _api$engagementPlatfo : {};
|
|
12
|
+
var isActive = messageStates[messageId];
|
|
13
|
+
if (isActive === false) {
|
|
14
|
+
return Promise.resolve(true);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// If there is already a stop message promise, return it to prevent multiple stop requests
|
|
18
|
+
var stopMessagePromises = (_api$engagementPlatfo3 = (_api$engagementPlatfo4 = api.engagementPlatform.sharedState.currentState()) === null || _api$engagementPlatfo4 === void 0 ? void 0 : _api$engagementPlatfo4.stopMessagePromises) !== null && _api$engagementPlatfo3 !== void 0 ? _api$engagementPlatfo3 : {};
|
|
19
|
+
var stopMessagePromise = stopMessagePromises[messageId];
|
|
20
|
+
if (stopMessagePromise) {
|
|
21
|
+
return stopMessagePromise;
|
|
22
|
+
}
|
|
23
|
+
var newStopMessagePromise = coordinationClient.stop(messageId).then(function (isStopped) {
|
|
24
|
+
// Update the message state in the shared state
|
|
25
|
+
if (isStopped) {
|
|
26
|
+
api.core.actions.execute(engagementPlatformPmPluginCommand({
|
|
27
|
+
type: 'setMessageState',
|
|
28
|
+
messageId: messageId,
|
|
29
|
+
state: false
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
return isStopped;
|
|
33
|
+
}).catch(function (error) {
|
|
34
|
+
var _api$analytics;
|
|
35
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
|
|
36
|
+
action: ACTION.ERRORED,
|
|
37
|
+
actionSubject: ACTION_SUBJECT.ENGAGEMENT_PLATFORM,
|
|
38
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
39
|
+
attributes: {
|
|
40
|
+
error: error instanceof Error ? error.message : "".concat(error),
|
|
41
|
+
errorStack: error instanceof Error ? error.stack : undefined
|
|
52
42
|
}
|
|
53
|
-
}
|
|
43
|
+
});
|
|
44
|
+
return false;
|
|
45
|
+
}).finally(function () {
|
|
46
|
+
// Remove the promise from the state after it has been resolved
|
|
47
|
+
api.core.actions.execute(engagementPlatformPmPluginCommand({
|
|
48
|
+
type: 'setStopMessagePromise',
|
|
49
|
+
messageId: messageId,
|
|
50
|
+
promise: undefined
|
|
51
|
+
}));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Store the promise in the shared state to prevent multiple stop requests for the same message
|
|
55
|
+
api.core.actions.execute(engagementPlatformPmPluginCommand({
|
|
56
|
+
type: 'setStopMessagePromise',
|
|
57
|
+
messageId: messageId,
|
|
58
|
+
promise: newStopMessagePromise
|
|
54
59
|
}));
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
}();
|
|
60
|
+
return newStopMessagePromise;
|
|
61
|
+
};
|
|
59
62
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
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; } } }; }
|
|
7
|
+
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; } }
|
|
8
|
+
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; }
|
|
3
9
|
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; }
|
|
4
10
|
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; }
|
|
5
11
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
@@ -11,6 +17,8 @@ export var engagementPlatformPmPlugin = function engagementPlatformPmPlugin(plug
|
|
|
11
17
|
init: function init() {
|
|
12
18
|
return {
|
|
13
19
|
messageStates: {},
|
|
20
|
+
startMessagePromises: {},
|
|
21
|
+
stopMessagePromises: {},
|
|
14
22
|
epComponents: pluginConfig.epComponents,
|
|
15
23
|
epHooks: pluginConfig.epHooks,
|
|
16
24
|
coordinationClient: pluginConfig.coordinationClient
|
|
@@ -21,20 +29,60 @@ export var engagementPlatformPmPlugin = function engagementPlatformPmPlugin(plug
|
|
|
21
29
|
if (!meta) {
|
|
22
30
|
return pluginState;
|
|
23
31
|
}
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
var state = _objectSpread({}, pluginState);
|
|
33
|
+
var _iterator = _createForOfIteratorHelper(meta.commands),
|
|
34
|
+
_step;
|
|
35
|
+
try {
|
|
36
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
37
|
+
var command = _step.value;
|
|
38
|
+
switch (command.type) {
|
|
39
|
+
case 'setMessageState':
|
|
40
|
+
state = _objectSpread(_objectSpread({}, state), {}, {
|
|
41
|
+
messageStates: _objectSpread(_objectSpread({}, state.messageStates), {}, _defineProperty({}, command.messageId, command.state))
|
|
42
|
+
});
|
|
43
|
+
break;
|
|
44
|
+
case 'setStartMessagePromise':
|
|
45
|
+
if (command.promise !== undefined) {
|
|
46
|
+
state = _objectSpread(_objectSpread({}, state), {}, {
|
|
47
|
+
startMessagePromises: _objectSpread(_objectSpread({}, state.startMessagePromises), {}, _defineProperty({}, command.messageId, command.promise))
|
|
48
|
+
});
|
|
49
|
+
break;
|
|
50
|
+
} else {
|
|
51
|
+
// If the promise is undefined, remove it from the state
|
|
52
|
+
var _state$startMessagePr = state.startMessagePromises,
|
|
53
|
+
_command$messageId = command.messageId,
|
|
54
|
+
_ = _state$startMessagePr[_command$messageId],
|
|
55
|
+
startMessagePromises = _objectWithoutProperties(_state$startMessagePr, [_command$messageId].map(_toPropertyKey));
|
|
56
|
+
state = _objectSpread(_objectSpread({}, state), {}, {
|
|
57
|
+
startMessagePromises: startMessagePromises
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
case 'setStopMessagePromise':
|
|
62
|
+
if (command.promise !== undefined) {
|
|
63
|
+
state = _objectSpread(_objectSpread({}, state), {}, {
|
|
64
|
+
stopMessagePromises: _objectSpread(_objectSpread({}, state.stopMessagePromises), {}, _defineProperty({}, command.messageId, command.promise))
|
|
65
|
+
});
|
|
66
|
+
break;
|
|
67
|
+
} else {
|
|
68
|
+
// If the promise is undefined, remove it from the state
|
|
69
|
+
var _state$stopMessagePro = state.stopMessagePromises,
|
|
70
|
+
_command$messageId2 = command.messageId,
|
|
71
|
+
_2 = _state$stopMessagePro[_command$messageId2],
|
|
72
|
+
stopMessagePromises = _objectWithoutProperties(_state$stopMessagePro, [_command$messageId2].map(_toPropertyKey));
|
|
73
|
+
state = _objectSpread(_objectSpread({}, state), {}, {
|
|
74
|
+
stopMessagePromises: stopMessagePromises
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
35
79
|
}
|
|
36
|
-
})
|
|
37
|
-
|
|
80
|
+
} catch (err) {
|
|
81
|
+
_iterator.e(err);
|
|
82
|
+
} finally {
|
|
83
|
+
_iterator.f();
|
|
84
|
+
}
|
|
85
|
+
return state;
|
|
38
86
|
}
|
|
39
87
|
}
|
|
40
88
|
});
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
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; }
|
|
3
4
|
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; }
|
|
4
|
-
import { engagementPlatformPmPluginKey } from '
|
|
5
|
-
|
|
6
|
-
export var setMessageState = function setMessageState(messageIs, state) {
|
|
5
|
+
import { engagementPlatformPmPluginKey } from './engagementPlatformPmPluginKey';
|
|
6
|
+
export var engagementPlatformPmPluginCommand = function engagementPlatformPmPluginCommand(command) {
|
|
7
7
|
return function (_ref) {
|
|
8
8
|
var _tr$getMeta;
|
|
9
9
|
var tr = _ref.tr;
|
|
10
|
-
var
|
|
11
|
-
|
|
10
|
+
var currentMeta = (_tr$getMeta = tr.getMeta(engagementPlatformPmPluginKey)) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : {
|
|
11
|
+
commands: []
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
var newMeta = _objectSpread(_objectSpread({}, currentMeta), {}, {
|
|
14
|
+
commands: [].concat(_toConsumableArray(currentMeta.commands), [command])
|
|
15
|
+
});
|
|
16
|
+
return tr.setMeta(engagementPlatformPmPluginKey, newMeta);
|
|
14
17
|
};
|
|
15
18
|
};
|
|
@@ -8,18 +8,48 @@ export interface EngagementPlatformPmPluginState {
|
|
|
8
8
|
messageStates: {
|
|
9
9
|
[messageId: string]: boolean;
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Promise for each message that has been started.
|
|
13
|
+
*
|
|
14
|
+
* This is used to prevent multiple start requests for the same message.
|
|
15
|
+
*/
|
|
16
|
+
startMessagePromises: {
|
|
17
|
+
[messageId: string]: Promise<boolean>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Promise for each message that has been stopped.
|
|
21
|
+
*
|
|
22
|
+
* This is used to prevent multiple stop requests for the same message.
|
|
23
|
+
*/
|
|
24
|
+
stopMessagePromises: {
|
|
25
|
+
[messageId: string]: Promise<boolean>;
|
|
26
|
+
};
|
|
11
27
|
/** Engagement Platform coordination client */
|
|
12
28
|
coordinationClient: CoordinationClient;
|
|
13
29
|
epComponents: EpComponents;
|
|
14
30
|
epHooks: EpHooks;
|
|
15
31
|
}
|
|
32
|
+
/** Command to EP plugin, that set state of a message with given ID. */
|
|
33
|
+
export interface SetMessageStateCommand {
|
|
34
|
+
type: 'setMessageState';
|
|
35
|
+
messageId: string;
|
|
36
|
+
state: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** Command to EP plugin, that set promise for starting a message with given ID. */
|
|
39
|
+
export interface SetStartMessagePromiseCommand {
|
|
40
|
+
type: 'setStartMessagePromise';
|
|
41
|
+
messageId: string;
|
|
42
|
+
promise: Promise<boolean> | undefined;
|
|
43
|
+
}
|
|
44
|
+
/** Command to EP plugin, that set promise for stopping a message with given ID. */
|
|
45
|
+
export interface SetStopMessagePromiseCommand {
|
|
46
|
+
type: 'setStopMessagePromise';
|
|
47
|
+
messageId: string;
|
|
48
|
+
promise: Promise<boolean> | undefined;
|
|
49
|
+
}
|
|
50
|
+
/** Commands that can be applied to the Engagement Platform plugin state. */
|
|
51
|
+
export type EngagementPlatformPmPluginCommand = SetMessageStateCommand | SetStartMessagePromiseCommand | SetStopMessagePromiseCommand;
|
|
16
52
|
export interface EngagementPlatformPmPluginTrMeta {
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
* This state will be merged (NOT REPLACED) with the existing state.
|
|
21
|
-
*/
|
|
22
|
-
newMessageStates: {
|
|
23
|
-
[messageId: string]: boolean;
|
|
24
|
-
};
|
|
53
|
+
/** List of commands that should be applied to the Engagement Platform plugin state. */
|
|
54
|
+
commands: EngagementPlatformPmPluginCommand[];
|
|
25
55
|
}
|
|
@@ -8,18 +8,48 @@ export interface EngagementPlatformPmPluginState {
|
|
|
8
8
|
messageStates: {
|
|
9
9
|
[messageId: string]: boolean;
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Promise for each message that has been started.
|
|
13
|
+
*
|
|
14
|
+
* This is used to prevent multiple start requests for the same message.
|
|
15
|
+
*/
|
|
16
|
+
startMessagePromises: {
|
|
17
|
+
[messageId: string]: Promise<boolean>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Promise for each message that has been stopped.
|
|
21
|
+
*
|
|
22
|
+
* This is used to prevent multiple stop requests for the same message.
|
|
23
|
+
*/
|
|
24
|
+
stopMessagePromises: {
|
|
25
|
+
[messageId: string]: Promise<boolean>;
|
|
26
|
+
};
|
|
11
27
|
/** Engagement Platform coordination client */
|
|
12
28
|
coordinationClient: CoordinationClient;
|
|
13
29
|
epComponents: EpComponents;
|
|
14
30
|
epHooks: EpHooks;
|
|
15
31
|
}
|
|
32
|
+
/** Command to EP plugin, that set state of a message with given ID. */
|
|
33
|
+
export interface SetMessageStateCommand {
|
|
34
|
+
type: 'setMessageState';
|
|
35
|
+
messageId: string;
|
|
36
|
+
state: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** Command to EP plugin, that set promise for starting a message with given ID. */
|
|
39
|
+
export interface SetStartMessagePromiseCommand {
|
|
40
|
+
type: 'setStartMessagePromise';
|
|
41
|
+
messageId: string;
|
|
42
|
+
promise: Promise<boolean> | undefined;
|
|
43
|
+
}
|
|
44
|
+
/** Command to EP plugin, that set promise for stopping a message with given ID. */
|
|
45
|
+
export interface SetStopMessagePromiseCommand {
|
|
46
|
+
type: 'setStopMessagePromise';
|
|
47
|
+
messageId: string;
|
|
48
|
+
promise: Promise<boolean> | undefined;
|
|
49
|
+
}
|
|
50
|
+
/** Commands that can be applied to the Engagement Platform plugin state. */
|
|
51
|
+
export type EngagementPlatformPmPluginCommand = SetMessageStateCommand | SetStartMessagePromiseCommand | SetStopMessagePromiseCommand;
|
|
16
52
|
export interface EngagementPlatformPmPluginTrMeta {
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
* This state will be merged (NOT REPLACED) with the existing state.
|
|
21
|
-
*/
|
|
22
|
-
newMessageStates: {
|
|
23
|
-
[messageId: string]: boolean;
|
|
24
|
-
};
|
|
53
|
+
/** List of commands that should be applied to the Engagement Platform plugin state. */
|
|
54
|
+
commands: EngagementPlatformPmPluginCommand[];
|
|
25
55
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-engagement-platform",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Engagement platform plugin for @atlaskit/editor-core“",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"inPublicMirror": false,
|
|
13
13
|
"singleton": true,
|
|
14
14
|
"releaseModel": "continuous",
|
|
15
|
-
"runReact18":
|
|
15
|
+
"runReact18": true
|
|
16
16
|
},
|
|
17
17
|
"repository": "https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo",
|
|
18
18
|
"main": "dist/cjs/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
".": "./src/index.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/editor-common": "^94.
|
|
36
|
+
"@atlaskit/editor-common": "^94.3.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
38
38
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
39
39
|
"@babel/runtime": "^7.0.0"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { engagementPlatformPmPluginKey } from '../engagementPlatformPmPluginKey';
|
|
2
|
-
/** Set the state of a message in the Engagement Platform plugin */
|
|
3
|
-
export const setMessageState = (messageIs, state) => ({
|
|
4
|
-
tr
|
|
5
|
-
}) => {
|
|
6
|
-
var _tr$getMeta;
|
|
7
|
-
const meta = {
|
|
8
|
-
newMessageStates: {
|
|
9
|
-
...((_tr$getMeta = tr.getMeta(engagementPlatformPmPluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.messageStates),
|
|
10
|
-
[messageIs]: state
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
return tr.setMeta(engagementPlatformPmPluginKey, meta);
|
|
14
|
-
};
|