stream-chat 8.18.0 → 8.18.2

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/dist/index.js CHANGED
@@ -188,6 +188,7 @@ function isOwnUserBaseProperty(property) {
188
188
  total_unread_count: true,
189
189
  unread_channels: true,
190
190
  unread_count: true,
191
+ unread_threads: true,
191
192
  invisible: true,
192
193
  roles: true
193
194
  };
@@ -6269,28 +6270,17 @@ var Campaign = /*#__PURE__*/function () {
6269
6270
  return _delete;
6270
6271
  }()
6271
6272
  }, {
6272
- key: "schedule",
6273
+ key: "stop",
6273
6274
  value: function () {
6274
- var _schedule = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(params) {
6275
- var scheduledFor, _yield$this$client$pa, campaign;
6276
-
6275
+ var _stop = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5() {
6277
6276
  return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
6278
6277
  while (1) {
6279
6278
  switch (_context5.prev = _context5.next) {
6280
6279
  case 0:
6281
6280
  this.verifyCampaignId();
6282
- scheduledFor = params.scheduledFor;
6283
- _context5.next = 4;
6284
- return this.client.patch(this.client.baseURL + "/campaigns/".concat(this.id, "/schedule"), {
6285
- scheduled_for: scheduledFor
6286
- });
6287
-
6288
- case 4:
6289
- _yield$this$client$pa = _context5.sent;
6290
- campaign = _yield$this$client$pa.campaign;
6291
- return _context5.abrupt("return", campaign);
6281
+ return _context5.abrupt("return", this.client.patch(this.client.baseURL + "/campaigns/".concat(this.id, "/stop")));
6292
6282
 
6293
- case 7:
6283
+ case 2:
6294
6284
  case "end":
6295
6285
  return _context5.stop();
6296
6286
  }
@@ -6298,104 +6288,29 @@ var Campaign = /*#__PURE__*/function () {
6298
6288
  }, _callee5, this);
6299
6289
  }));
6300
6290
 
6301
- function schedule(_x3) {
6302
- return _schedule.apply(this, arguments);
6303
- }
6304
-
6305
- return schedule;
6306
- }()
6307
- }, {
6308
- key: "stop",
6309
- value: function () {
6310
- var _stop = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
6311
- return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
6312
- while (1) {
6313
- switch (_context6.prev = _context6.next) {
6314
- case 0:
6315
- this.verifyCampaignId();
6316
- return _context6.abrupt("return", this.client.patch(this.client.baseURL + "/campaigns/".concat(this.id, "/stop")));
6317
-
6318
- case 2:
6319
- case "end":
6320
- return _context6.stop();
6321
- }
6322
- }
6323
- }, _callee6, this);
6324
- }));
6325
-
6326
6291
  function stop() {
6327
6292
  return _stop.apply(this, arguments);
6328
6293
  }
6329
6294
 
6330
6295
  return stop;
6331
6296
  }()
6332
- }, {
6333
- key: "pause",
6334
- value: function () {
6335
- var _pause = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee7() {
6336
- return _regeneratorRuntime__default['default'].wrap(function _callee7$(_context7) {
6337
- while (1) {
6338
- switch (_context7.prev = _context7.next) {
6339
- case 0:
6340
- this.verifyCampaignId();
6341
- return _context7.abrupt("return", this.client.patch(this.client.baseURL + "/campaigns/".concat(this.id, "/pause")));
6342
-
6343
- case 2:
6344
- case "end":
6345
- return _context7.stop();
6346
- }
6347
- }
6348
- }, _callee7, this);
6349
- }));
6350
-
6351
- function pause() {
6352
- return _pause.apply(this, arguments);
6353
- }
6354
-
6355
- return pause;
6356
- }()
6357
- }, {
6358
- key: "resume",
6359
- value: function () {
6360
- var _resume = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee8() {
6361
- return _regeneratorRuntime__default['default'].wrap(function _callee8$(_context8) {
6362
- while (1) {
6363
- switch (_context8.prev = _context8.next) {
6364
- case 0:
6365
- this.verifyCampaignId();
6366
- return _context8.abrupt("return", this.client.patch(this.client.baseURL + "/campaigns/".concat(this.id, "/resume")));
6367
-
6368
- case 2:
6369
- case "end":
6370
- return _context8.stop();
6371
- }
6372
- }
6373
- }, _callee8, this);
6374
- }));
6375
-
6376
- function resume() {
6377
- return _resume.apply(this, arguments);
6378
- }
6379
-
6380
- return resume;
6381
- }()
6382
6297
  }, {
6383
6298
  key: "get",
6384
6299
  value: function () {
6385
- var _get = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee9() {
6386
- return _regeneratorRuntime__default['default'].wrap(function _callee9$(_context9) {
6300
+ var _get = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
6301
+ return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
6387
6302
  while (1) {
6388
- switch (_context9.prev = _context9.next) {
6303
+ switch (_context6.prev = _context6.next) {
6389
6304
  case 0:
6390
6305
  this.verifyCampaignId();
6391
- return _context9.abrupt("return", this.client.getCampaign(this.id));
6306
+ return _context6.abrupt("return", this.client.getCampaign(this.id));
6392
6307
 
6393
6308
  case 2:
6394
6309
  case "end":
6395
- return _context9.stop();
6310
+ return _context6.stop();
6396
6311
  }
6397
6312
  }
6398
- }, _callee9, this);
6313
+ }, _callee6, this);
6399
6314
  }));
6400
6315
 
6401
6316
  function get() {
@@ -6782,20 +6697,22 @@ var Thread = /*#__PURE__*/function () {
6782
6697
  this._channel = client.channel(t.channel.type, t.channel.id);
6783
6698
  this._client = client;
6784
6699
 
6785
- var _iterator = _createForOfIteratorHelper$1(t.read),
6786
- _step;
6700
+ if (t.read) {
6701
+ var _iterator = _createForOfIteratorHelper$1(t.read),
6702
+ _step;
6787
6703
 
6788
- try {
6789
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
6790
- var r = _step.value;
6791
- this.read[r.user.id] = _objectSpread$1(_objectSpread$1({}, r), {}, {
6792
- last_read: new Date(r.last_read)
6793
- });
6704
+ try {
6705
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
6706
+ var r = _step.value;
6707
+ this.read[r.user.id] = _objectSpread$1(_objectSpread$1({}, r), {}, {
6708
+ last_read: new Date(r.last_read)
6709
+ });
6710
+ }
6711
+ } catch (err) {
6712
+ _iterator.e(err);
6713
+ } finally {
6714
+ _iterator.f();
6794
6715
  }
6795
- } catch (err) {
6796
- _iterator.e(err);
6797
- } finally {
6798
- _iterator.f();
6799
6716
  }
6800
6717
  }
6801
6718
 
@@ -6804,10 +6721,20 @@ var Thread = /*#__PURE__*/function () {
6804
6721
  value: function getClient() {
6805
6722
  return this._client;
6806
6723
  }
6724
+ /**
6725
+ * addReply - Adds or updates a latestReplies to the thread
6726
+ *
6727
+ * @param {MessageResponse<StreamChatGenerics>} message reply message to be added.
6728
+ */
6729
+
6807
6730
  }, {
6808
6731
  key: "addReply",
6809
6732
  value: function addReply(message) {
6810
- this.latestReplies = addToMessageList(this.latestReplies, formatMessage(message));
6733
+ if (message.parent_id !== this.message.id) {
6734
+ throw new Error('Message does not belong to this thread');
6735
+ }
6736
+
6737
+ this.latestReplies = addToMessageList(this.latestReplies, formatMessage(message), true);
6811
6738
  }
6812
6739
  }, {
6813
6740
  key: "updateReply",
@@ -6833,6 +6760,7 @@ var Thread = /*#__PURE__*/function () {
6833
6760
 
6834
6761
  if (message.parent_id && message.parent_id === this.message.id) {
6835
6762
  this.updateReply(message);
6763
+ return;
6836
6764
  }
6837
6765
 
6838
6766
  if (!message.parent_id && message.id === this.message.id) {
@@ -11173,7 +11101,7 @@ var StreamChat = /*#__PURE__*/function () {
11173
11101
  }, {
11174
11102
  key: "getUserAgent",
11175
11103
  value: function getUserAgent() {
11176
- return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.18.0");
11104
+ return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "8.18.2");
11177
11105
  }
11178
11106
  }, {
11179
11107
  key: "setUserAgent",