@twilio/conversations 2.6.4 → 2.6.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.
@@ -15695,7 +15695,7 @@ this.Twilio.Conversations = (function (exports) {
15695
15695
  }();
15696
15696
 
15697
15697
  var logInstance = new Logger("");
15698
- var version = "0.13.11";
15698
+ var version = "0.13.12";
15699
15699
  /**
15700
15700
  * Settings container for the Twilsock client library
15701
15701
  */
@@ -34307,7 +34307,7 @@ this.Twilio.Conversations = (function (exports) {
34307
34307
  return Network;
34308
34308
  }();
34309
34309
 
34310
- var version = "0.6.12";
34310
+ var version = "0.6.13";
34311
34311
 
34312
34312
  var _class;
34313
34313
 
@@ -38700,6 +38700,10 @@ this.Twilio.Conversations = (function (exports) {
38700
38700
  * Promise for the conversation entity document.
38701
38701
  */
38702
38702
 
38703
+ /**
38704
+ * Promise for the messages list.
38705
+ */
38706
+
38703
38707
  /**
38704
38708
  * Conversation entity document.
38705
38709
  */
@@ -39982,44 +39986,95 @@ this.Twilio.Conversations = (function (exports) {
39982
39986
  }, {
39983
39987
  key: "_fetchStreams",
39984
39988
  value: function () {
39985
- var _fetchStreams2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee26() {
39986
- var _this$_entity, _this$_entity2;
39989
+ var _fetchStreams2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee27() {
39990
+ var _this3 = this;
39987
39991
 
39988
- var data;
39989
- return _regeneratorRuntime$1.wrap(function _callee26$(_context26) {
39992
+ return _regeneratorRuntime$1.wrap(function _callee27$(_context27) {
39990
39993
  while (1) {
39991
- switch (_context26.prev = _context26.next) {
39994
+ switch (_context27.prev = _context27.next) {
39992
39995
  case 0:
39993
- _context26.next = 2;
39994
- return this._subscribe();
39996
+ if (!this._streamsPromise) {
39997
+ _context27.next = 2;
39998
+ break;
39999
+ }
39995
40000
 
39996
- case 2:
39997
- Conversation._logger.trace("_streamsAvailable, this.entity.data=", (_this$_entity = this._entity) === null || _this$_entity === void 0 ? void 0 : _this$_entity.data);
40001
+ return _context27.abrupt("return", this._streamsPromise);
39998
40002
 
39999
- data = (_this$_entity2 = this._entity) === null || _this$_entity2 === void 0 ? void 0 : _this$_entity2.data;
40000
- _context26.next = 6;
40001
- return this._services.syncClient.list({
40002
- id: data.messages,
40003
- mode: "open_existing"
40004
- });
40003
+ case 2:
40004
+ this._streamsPromise = new Promise( /*#__PURE__*/function () {
40005
+ var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee26(resolve, reject) {
40006
+ var _this3$_entity, _this3$_entity2;
40007
+
40008
+ var data, messagesPromise, participantsPromise;
40009
+ return _regeneratorRuntime$1.wrap(function _callee26$(_context26) {
40010
+ while (1) {
40011
+ switch (_context26.prev = _context26.next) {
40012
+ case 0:
40013
+ _context26.prev = 0;
40014
+ _context26.next = 3;
40015
+ return _this3._subscribe();
40016
+
40017
+ case 3:
40018
+ _context26.next = 9;
40019
+ break;
40005
40020
 
40006
- case 6:
40007
- this._messagesList = _context26.sent;
40008
- _context26.next = 9;
40009
- return this._services.syncClient.map({
40010
- id: data.roster,
40011
- mode: "open_existing"
40012
- });
40021
+ case 5:
40022
+ _context26.prev = 5;
40023
+ _context26.t0 = _context26["catch"](0);
40024
+
40025
+ Conversation._logger.trace("Failed to subscribe to conversation", _context26.t0);
40026
+
40027
+ return _context26.abrupt("return", reject(_context26.t0));
40028
+
40029
+ case 9:
40030
+ Conversation._logger.trace("_streamsAvailable, this.entity.data=", (_this3$_entity = _this3._entity) === null || _this3$_entity === void 0 ? void 0 : _this3$_entity.data);
40031
+
40032
+ data = (_this3$_entity2 = _this3._entity) === null || _this3$_entity2 === void 0 ? void 0 : _this3$_entity2.data;
40033
+ messagesPromise = _this3._services.syncClient.list({
40034
+ id: data.messages,
40035
+ mode: "open_existing"
40036
+ }).then(function (list) {
40037
+ _this3._messagesList = list;
40038
+ return list;
40039
+ });
40040
+ participantsPromise = _this3._services.syncClient.map({
40041
+ id: data.roster,
40042
+ mode: "open_existing"
40043
+ }).then(function (map) {
40044
+ _this3._participantsMap = map;
40045
+ return map;
40046
+ });
40047
+ Promise.all([messagesPromise, participantsPromise]).then(function () {
40048
+ return resolve(true);
40049
+ }).catch(function (err) {
40050
+ Conversation._logger.trace("Failed to fetch conversation streams for conversation", _this3.sid, err);
40051
+
40052
+ reject(err);
40053
+ });
40054
+
40055
+ case 14:
40056
+ case "end":
40057
+ return _context26.stop();
40058
+ }
40059
+ }
40060
+ }, _callee26, null, [[0, 5]]);
40061
+ }));
40013
40062
 
40014
- case 9:
40015
- this._participantsMap = _context26.sent;
40063
+ return function (_x20, _x21) {
40064
+ return _ref.apply(this, arguments);
40065
+ };
40066
+ }());
40067
+ return _context27.abrupt("return", this._streamsPromise.catch(function (err) {
40068
+ _this3._streamsPromise = null;
40069
+ throw err;
40070
+ }));
40016
40071
 
40017
- case 10:
40072
+ case 4:
40018
40073
  case "end":
40019
- return _context26.stop();
40074
+ return _context27.stop();
40020
40075
  }
40021
40076
  }
40022
- }, _callee26, this);
40077
+ }, _callee27, this);
40023
40078
  }));
40024
40079
 
40025
40080
  function _fetchStreams() {
@@ -40039,48 +40094,48 @@ this.Twilio.Conversations = (function (exports) {
40039
40094
  }, {
40040
40095
  key: "_subscribeStreams",
40041
40096
  value: function () {
40042
- var _subscribeStreams2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee27() {
40043
- var _this$_entity3, _this$_entity4, _this$_messagesList, _this$_participantsMa, data, messagesObjectName, rosterObjectName;
40097
+ var _subscribeStreams2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee28() {
40098
+ var _this$_entity, _this$_entity2, _this$_messagesList, _this$_participantsMa, data, messagesObjectName, rosterObjectName;
40044
40099
 
40045
- return _regeneratorRuntime$1.wrap(function _callee27$(_context27) {
40100
+ return _regeneratorRuntime$1.wrap(function _callee28$(_context28) {
40046
40101
  while (1) {
40047
- switch (_context27.prev = _context27.next) {
40102
+ switch (_context28.prev = _context28.next) {
40048
40103
  case 0:
40049
- _context27.prev = 0;
40050
- _context27.next = 3;
40051
- return this._subscribe();
40104
+ _context28.prev = 0;
40105
+ _context28.next = 3;
40106
+ return this._fetchStreams();
40052
40107
 
40053
40108
  case 3:
40054
- Conversation._logger.trace("_subscribeStreams, this.entity.data=", (_this$_entity3 = this._entity) === null || _this$_entity3 === void 0 ? void 0 : _this$_entity3.data);
40109
+ Conversation._logger.trace("_subscribeStreams, this.entity.data=", (_this$_entity = this._entity) === null || _this$_entity === void 0 ? void 0 : _this$_entity.data);
40055
40110
 
40056
- data = (_this$_entity4 = this._entity) === null || _this$_entity4 === void 0 ? void 0 : _this$_entity4.data;
40111
+ data = (_this$_entity2 = this._entity) === null || _this$_entity2 === void 0 ? void 0 : _this$_entity2.data;
40057
40112
  messagesObjectName = data.messages;
40058
40113
  rosterObjectName = data.roster;
40059
- _context27.next = 9;
40114
+ _context28.next = 9;
40060
40115
  return Promise.all([this._messagesEntity.subscribe((_this$_messagesList = this._messagesList) !== null && _this$_messagesList !== void 0 ? _this$_messagesList : messagesObjectName), this._participantsEntity.subscribe((_this$_participantsMa = this._participantsMap) !== null && _this$_participantsMa !== void 0 ? _this$_participantsMa : rosterObjectName)]);
40061
40116
 
40062
40117
  case 9:
40063
- _context27.next = 16;
40118
+ _context28.next = 16;
40064
40119
  break;
40065
40120
 
40066
40121
  case 11:
40067
- _context27.prev = 11;
40068
- _context27.t0 = _context27["catch"](0);
40122
+ _context28.prev = 11;
40123
+ _context28.t0 = _context28["catch"](0);
40069
40124
 
40070
40125
  if (this._services.syncClient.connectionState !== "disconnected") {
40071
- Conversation._logger.error("Failed to subscribe on conversation objects", this.sid, _context27.t0);
40126
+ Conversation._logger.error("Failed to subscribe on conversation objects", this.sid, _context28.t0);
40072
40127
  }
40073
40128
 
40074
- Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context27.t0);
40129
+ Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects", this.sid, _context28.t0);
40075
40130
 
40076
- throw _context27.t0;
40131
+ throw _context28.t0;
40077
40132
 
40078
40133
  case 16:
40079
40134
  case "end":
40080
- return _context27.stop();
40135
+ return _context28.stop();
40081
40136
  }
40082
40137
  }
40083
- }, _callee27, this, [[0, 11]]);
40138
+ }, _callee28, this, [[0, 11]]);
40084
40139
  }));
40085
40140
 
40086
40141
  function _subscribeStreams() {
@@ -40097,10 +40152,10 @@ this.Twilio.Conversations = (function (exports) {
40097
40152
  }, {
40098
40153
  key: "_unsubscribe",
40099
40154
  value: function () {
40100
- var _unsubscribe2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee28() {
40101
- return _regeneratorRuntime$1.wrap(function _callee28$(_context28) {
40155
+ var _unsubscribe2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee29() {
40156
+ return _regeneratorRuntime$1.wrap(function _callee29$(_context29) {
40102
40157
  while (1) {
40103
- switch (_context28.prev = _context28.next) {
40158
+ switch (_context29.prev = _context29.next) {
40104
40159
  case 0:
40105
40160
  if (this._entity) {
40106
40161
  this._entity.close();
@@ -40109,14 +40164,14 @@ this.Twilio.Conversations = (function (exports) {
40109
40164
  this._entityPromise = null;
40110
40165
  }
40111
40166
 
40112
- return _context28.abrupt("return", Promise.all([this._participantsEntity.unsubscribe(), this._messagesEntity.unsubscribe()]));
40167
+ return _context29.abrupt("return", Promise.all([this._participantsEntity.unsubscribe(), this._messagesEntity.unsubscribe()]));
40113
40168
 
40114
40169
  case 2:
40115
40170
  case "end":
40116
- return _context28.stop();
40171
+ return _context29.stop();
40117
40172
  }
40118
40173
  }
40119
- }, _callee28, this);
40174
+ }, _callee29, this);
40120
40175
  }));
40121
40176
 
40122
40177
  function _unsubscribe() {
@@ -40133,7 +40188,7 @@ this.Twilio.Conversations = (function (exports) {
40133
40188
  }, {
40134
40189
  key: "_setStatus",
40135
40190
  value: function _setStatus(status, source) {
40136
- var _this3 = this;
40191
+ var _this4 = this;
40137
40192
 
40138
40193
  this._dataSource = source;
40139
40194
 
@@ -40147,7 +40202,7 @@ this.Twilio.Conversations = (function (exports) {
40147
40202
  this._subscribeStreams().catch(function (err) {
40148
40203
  Conversation._logger.debug("ERROR while setting conversation status " + status, err);
40149
40204
 
40150
- if (_this3._services.syncClient.connectionState !== "disconnected") {
40205
+ if (_this4._services.syncClient.connectionState !== "disconnected") {
40151
40206
  throw err;
40152
40207
  }
40153
40208
  });
@@ -40159,7 +40214,7 @@ this.Twilio.Conversations = (function (exports) {
40159
40214
  this._unsubscribe().catch(function (err) {
40160
40215
  Conversation._logger.debug("ERROR while setting conversation status " + status, err);
40161
40216
 
40162
- if (_this3._services.syncClient.connectionState !== "disconnected") {
40217
+ if (_this4._services.syncClient.connectionState !== "disconnected") {
40163
40218
  throw err;
40164
40219
  }
40165
40220
  });
@@ -40322,30 +40377,30 @@ this.Twilio.Conversations = (function (exports) {
40322
40377
  }, {
40323
40378
  key: "_setLastReadMessageIndex",
40324
40379
  value: function () {
40325
- var _setLastReadMessageIndex2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee29(index) {
40380
+ var _setLastReadMessageIndex2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee30(index) {
40326
40381
  var result;
40327
- return _regeneratorRuntime$1.wrap(function _callee29$(_context29) {
40382
+ return _regeneratorRuntime$1.wrap(function _callee30$(_context30) {
40328
40383
  while (1) {
40329
- switch (_context29.prev = _context29.next) {
40384
+ switch (_context30.prev = _context30.next) {
40330
40385
  case 0:
40331
- _context29.next = 2;
40386
+ _context30.next = 2;
40332
40387
  return this._services.commandExecutor.mutateResource("post", "".concat(this._configuration.links.myConversations, "/").concat(this.sid), {
40333
40388
  last_read_message_index: index
40334
40389
  });
40335
40390
 
40336
40391
  case 2:
40337
- result = _context29.sent;
40338
- return _context29.abrupt("return", result.unread_messages_count);
40392
+ result = _context30.sent;
40393
+ return _context30.abrupt("return", result.unread_messages_count);
40339
40394
 
40340
40395
  case 4:
40341
40396
  case "end":
40342
- return _context29.stop();
40397
+ return _context30.stop();
40343
40398
  }
40344
40399
  }
40345
- }, _callee29, this);
40400
+ }, _callee30, this);
40346
40401
  }));
40347
40402
 
40348
- function _setLastReadMessageIndex(_x20) {
40403
+ function _setLastReadMessageIndex(_x22) {
40349
40404
  return _setLastReadMessageIndex2.apply(this, arguments);
40350
40405
  }
40351
40406
 
@@ -41793,7 +41848,7 @@ this.Twilio.Conversations = (function (exports) {
41793
41848
  this.data = data.data || {};
41794
41849
  });
41795
41850
 
41796
- var version = "2.6.4";
41851
+ var version = "2.6.5";
41797
41852
 
41798
41853
  function _isNativeFunction(fn) {
41799
41854
  return Function.toString.call(fn).indexOf("[native code]") !== -1;