stream-chat-react-native-core 5.36.1-beta.1 → 5.36.1-beta.3

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.
Files changed (44) hide show
  1. package/lib/commonjs/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
  2. package/lib/commonjs/components/ChannelList/ChannelListMessenger.js +0 -5
  3. package/lib/commonjs/components/ChannelList/ChannelListMessenger.js.map +1 -1
  4. package/lib/commonjs/components/MessageInput/FileUploadPreview.js +1 -0
  5. package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
  6. package/lib/commonjs/components/MessageInput/MessageInput.js +116 -47
  7. package/lib/commonjs/components/MessageInput/MessageInput.js.map +1 -1
  8. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +283 -226
  9. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  10. package/lib/commonjs/contexts/messageInputContext/hooks/useMessageDetailsForState.js +11 -5
  11. package/lib/commonjs/contexts/messageInputContext/hooks/useMessageDetailsForState.js.map +1 -1
  12. package/lib/commonjs/version.json +1 -1
  13. package/lib/module/components/AttachmentPicker/components/AttachmentPickerItem.js.map +1 -1
  14. package/lib/module/components/ChannelList/ChannelListMessenger.js +0 -5
  15. package/lib/module/components/ChannelList/ChannelListMessenger.js.map +1 -1
  16. package/lib/module/components/MessageInput/FileUploadPreview.js +1 -0
  17. package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
  18. package/lib/module/components/MessageInput/MessageInput.js +116 -47
  19. package/lib/module/components/MessageInput/MessageInput.js.map +1 -1
  20. package/lib/module/contexts/messageInputContext/MessageInputContext.js +283 -226
  21. package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  22. package/lib/module/contexts/messageInputContext/hooks/useMessageDetailsForState.js +11 -5
  23. package/lib/module/contexts/messageInputContext/hooks/useMessageDetailsForState.js.map +1 -1
  24. package/lib/module/version.json +1 -1
  25. package/lib/typescript/components/AttachmentPicker/components/AttachmentPickerItem.d.ts +1 -1
  26. package/lib/typescript/components/AttachmentPicker/components/AttachmentPickerItem.d.ts.map +1 -1
  27. package/lib/typescript/components/ChannelList/ChannelListMessenger.d.ts.map +1 -1
  28. package/lib/typescript/components/MessageInput/FileUploadPreview.d.ts.map +1 -1
  29. package/lib/typescript/components/MessageInput/MessageInput.d.ts +1 -1
  30. package/lib/typescript/components/MessageInput/MessageInput.d.ts.map +1 -1
  31. package/lib/typescript/contexts/messageContext/MessageContext.d.ts +1 -1
  32. package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +1 -2
  33. package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts.map +1 -1
  34. package/lib/typescript/contexts/messageInputContext/hooks/useMessageDetailsForState.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/components/AttachmentPicker/components/AttachmentPickerItem.tsx +1 -2
  37. package/src/components/ChannelList/ChannelListMessenger.tsx +0 -4
  38. package/src/components/MessageInput/FileUploadPreview.tsx +1 -0
  39. package/src/components/MessageInput/MessageInput.tsx +65 -44
  40. package/src/contexts/messageInputContext/MessageInputContext.tsx +120 -91
  41. package/src/contexts/messageInputContext/__tests__/sendMessage.test.tsx +5 -0
  42. package/src/contexts/messageInputContext/__tests__/updateMessage.test.tsx +5 -0
  43. package/src/contexts/messageInputContext/hooks/useMessageDetailsForState.ts +8 -3
  44. package/src/version.json +1 -1
@@ -226,12 +226,13 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
226
226
  text: t('Open Settings')
227
227
  }]);
228
228
  }
229
- if (!photo.cancelled) {
230
- setSelectedImages(function (images) {
231
- return [].concat((0, _toConsumableArray2["default"])(images), [photo]);
232
- });
229
+ if (photo.cancelled) {
230
+ _context.next = 9;
231
+ break;
233
232
  }
234
- case 7:
233
+ _context.next = 9;
234
+ return uploadNewImage(photo);
235
+ case 9:
235
236
  case "end":
236
237
  return _context.stop();
237
238
  }
@@ -242,15 +243,15 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
242
243
  };
243
244
  }();
244
245
  var pickAndUploadImageFromNativePicker = function () {
245
- var _ref3 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2() {
246
+ var _ref3 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3() {
246
247
  var result;
247
- return _regenerator["default"].wrap(function _callee2$(_context2) {
248
- while (1) switch (_context2.prev = _context2.next) {
248
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
249
+ while (1) switch (_context3.prev = _context3.next) {
249
250
  case 0:
250
- _context2.next = 2;
251
+ _context3.next = 2;
251
252
  return (0, _native.pickImage)();
252
253
  case 2:
253
- result = _context2.sent;
254
+ result = _context3.sent;
254
255
  if (result.askToOpenSettings) {
255
256
  _reactNative.Alert.alert(t('Allow access to your Gallery'), t('Device gallery permissions is used to take photos or videos.'), [{
256
257
  style: 'cancel',
@@ -264,94 +265,124 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
264
265
  }]);
265
266
  }
266
267
  if (result.assets && result.assets.length > 0) {
267
- result.assets.forEach(function (asset) {
268
- if (asset.type.includes('image')) {
269
- setSelectedImages(function (prevImages) {
270
- return [].concat((0, _toConsumableArray2["default"])(prevImages), [asset]);
271
- });
272
- } else {
273
- setSelectedFiles(function (prevFiles) {
274
- return [].concat((0, _toConsumableArray2["default"])(prevFiles), [Object.assign({}, asset, {
275
- mimeType: asset.type,
276
- type: _types.FileTypes.Video
277
- })]);
278
- });
279
- }
280
- });
268
+ result.assets.forEach(function () {
269
+ var _ref4 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(asset) {
270
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
271
+ while (1) switch (_context2.prev = _context2.next) {
272
+ case 0:
273
+ if (!asset.type.includes('image')) {
274
+ _context2.next = 5;
275
+ break;
276
+ }
277
+ _context2.next = 3;
278
+ return uploadNewImage(asset);
279
+ case 3:
280
+ _context2.next = 7;
281
+ break;
282
+ case 5:
283
+ _context2.next = 7;
284
+ return uploadNewFile(Object.assign({}, asset, {
285
+ mimeType: asset.type,
286
+ type: _types.FileTypes.Video
287
+ }));
288
+ case 7:
289
+ case "end":
290
+ return _context2.stop();
291
+ }
292
+ }, _callee2);
293
+ }));
294
+ return function (_x) {
295
+ return _ref4.apply(this, arguments);
296
+ };
297
+ }());
281
298
  }
282
299
  case 5:
283
300
  case "end":
284
- return _context2.stop();
301
+ return _context3.stop();
285
302
  }
286
- }, _callee2);
303
+ }, _callee3);
287
304
  }));
288
305
  return function pickAndUploadImageFromNativePicker() {
289
306
  return _ref3.apply(this, arguments);
290
307
  };
291
308
  }();
292
- var openAttachmentPicker = function openAttachmentPicker() {
309
+ var openAttachmentPicker = (0, _react.useCallback)(function () {
293
310
  _reactNative.Keyboard.dismiss();
294
311
  setSelectedPicker('images');
295
312
  openPicker();
296
- };
297
- var closeAttachmentPicker = function closeAttachmentPicker() {
313
+ }, [openPicker, setSelectedPicker]);
314
+ var closeAttachmentPicker = (0, _react.useCallback)(function () {
298
315
  setSelectedPicker(undefined);
299
316
  closePicker();
300
- };
301
- var toggleAttachmentPicker = function toggleAttachmentPicker() {
317
+ }, [closePicker, setSelectedPicker]);
318
+ var toggleAttachmentPicker = (0, _react.useCallback)(function () {
302
319
  if (selectedPicker) {
303
320
  closeAttachmentPicker();
304
321
  } else {
305
322
  openAttachmentPicker();
306
323
  }
307
- };
324
+ }, [closeAttachmentPicker, openAttachmentPicker, selectedPicker]);
308
325
  var onSelectItem = function onSelectItem(item) {
309
326
  setMentionedUsers(function (prevMentionedUsers) {
310
327
  return [].concat((0, _toConsumableArray2["default"])(prevMentionedUsers), [item.id]);
311
328
  });
312
329
  };
313
330
  var pickFile = function () {
314
- var _ref4 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3() {
331
+ var _ref5 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5() {
315
332
  var result;
316
- return _regenerator["default"].wrap(function _callee3$(_context3) {
317
- while (1) switch (_context3.prev = _context3.next) {
333
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
334
+ while (1) switch (_context5.prev = _context5.next) {
318
335
  case 0:
319
336
  if (!(_native.pickDocument === null)) {
320
- _context3.next = 3;
337
+ _context5.next = 3;
321
338
  break;
322
339
  }
323
340
  console.log('The file picker is not installed. Check our Getting Started documentation to install it.');
324
- return _context3.abrupt("return");
341
+ return _context5.abrupt("return");
325
342
  case 3:
326
343
  if (!(numberOfUploads >= value.maxNumberOfFiles)) {
327
- _context3.next = 6;
344
+ _context5.next = 6;
328
345
  break;
329
346
  }
330
347
  _reactNative.Alert.alert('Maximum number of files reached');
331
- return _context3.abrupt("return");
348
+ return _context5.abrupt("return");
332
349
  case 6:
333
- _context3.next = 8;
350
+ _context5.next = 8;
334
351
  return (0, _native.pickDocument)({
335
352
  maxNumberOfFiles: value.maxNumberOfFiles - numberOfUploads
336
353
  });
337
354
  case 8:
338
- result = _context3.sent;
355
+ result = _context5.sent;
339
356
  if (!result.cancelled && result.assets) {
340
- result.assets.forEach(function (asset) {
341
- uploadNewFile(asset);
342
- });
357
+ result.assets.forEach(function () {
358
+ var _ref6 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(asset) {
359
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
360
+ while (1) switch (_context4.prev = _context4.next) {
361
+ case 0:
362
+ _context4.next = 2;
363
+ return uploadNewFile(asset);
364
+ case 2:
365
+ case "end":
366
+ return _context4.stop();
367
+ }
368
+ }, _callee4);
369
+ }));
370
+ return function (_x2) {
371
+ return _ref6.apply(this, arguments);
372
+ };
373
+ }());
343
374
  }
344
375
  case 10:
345
376
  case "end":
346
- return _context3.stop();
377
+ return _context5.stop();
347
378
  }
348
- }, _callee3);
379
+ }, _callee5);
349
380
  }));
350
381
  return function pickFile() {
351
- return _ref4.apply(this, arguments);
382
+ return _ref5.apply(this, arguments);
352
383
  };
353
384
  }();
354
- var removeFile = function removeFile(id) {
385
+ var removeFile = (0, _react.useCallback)(function (id) {
355
386
  if (fileUploads.some(function (file) {
356
387
  return file.id === id;
357
388
  })) {
@@ -364,8 +395,8 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
364
395
  return prevNumberOfUploads - 1;
365
396
  });
366
397
  }
367
- };
368
- var removeImage = function removeImage(id) {
398
+ }, [fileUploads, setFileUploads, setNumberOfUploads]);
399
+ var removeImage = (0, _react.useCallback)(function (id) {
369
400
  if (imageUploads.some(function (image) {
370
401
  return image.id === id;
371
402
  })) {
@@ -378,9 +409,13 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
378
409
  return prevNumberOfUploads - 1;
379
410
  });
380
411
  }
381
- };
412
+ }, [imageUploads, setImageUploads, setNumberOfUploads]);
382
413
  var resetInput = function resetInput() {
383
414
  var pendingAttachments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
415
+ if ((0, _native.isImageMediaLibraryAvailable)()) {
416
+ setSelectedFiles([]);
417
+ setSelectedImages([]);
418
+ }
384
419
  setFileUploads([]);
385
420
  setGiphyActive(false);
386
421
  setShowMoreOptions(true);
@@ -460,8 +495,8 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
460
495
  }
461
496
  };
462
497
  var sendMessage = function () {
463
- var _ref5 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4() {
464
- var _ref6,
498
+ var _ref7 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6() {
499
+ var _ref8,
465
500
  customMessageData,
466
501
  linkInfos,
467
502
  prevText,
@@ -477,24 +512,24 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
477
512
  message,
478
513
  updatedMessage,
479
514
  updateMessagePromise,
480
- _args5 = arguments;
481
- return _regenerator["default"].wrap(function _callee4$(_context5) {
482
- while (1) switch (_context5.prev = _context5.next) {
515
+ _args7 = arguments;
516
+ return _regenerator["default"].wrap(function _callee6$(_context7) {
517
+ while (1) switch (_context7.prev = _context7.next) {
483
518
  case 0:
484
- _ref6 = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, customMessageData = _ref6.customMessageData;
519
+ _ref8 = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {}, customMessageData = _ref8.customMessageData;
485
520
  if (!sending.current) {
486
- _context5.next = 3;
521
+ _context7.next = 3;
487
522
  break;
488
523
  }
489
- return _context5.abrupt("return");
524
+ return _context7.abrupt("return");
490
525
  case 3:
491
526
  linkInfos = (0, _parseLinks.parseLinksFromText)(text);
492
527
  if (!(!channelCapabities.sendLinks && linkInfos.length > 0)) {
493
- _context5.next = 7;
528
+ _context7.next = 7;
494
529
  break;
495
530
  }
496
531
  _reactNative.Alert.alert(t('Links are disabled'), t('Sending links is not allowed in this conversation'));
497
- return _context5.abrupt("return");
532
+ return _context7.abrupt("return");
498
533
  case 7:
499
534
  sending.current = true;
500
535
  startCooldown();
@@ -505,46 +540,46 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
505
540
  }
506
541
  attachments = [];
507
542
  _loop = _regenerator["default"].mark(function _loop(_image) {
508
- return _regenerator["default"].wrap(function _loop$(_context4) {
509
- while (1) switch (_context4.prev = _context4.next) {
543
+ return _regenerator["default"].wrap(function _loop$(_context6) {
544
+ while (1) switch (_context6.prev = _context6.next) {
510
545
  case 0:
511
546
  if (!enableOfflineSupport) {
512
- _context4.next = 5;
547
+ _context6.next = 5;
513
548
  break;
514
549
  }
515
550
  if (!(_image.state === _utils2.FileState.NOT_SUPPORTED)) {
516
- _context4.next = 3;
551
+ _context6.next = 3;
517
552
  break;
518
553
  }
519
- return _context4.abrupt("return", {
554
+ return _context6.abrupt("return", {
520
555
  v: void 0
521
556
  });
522
557
  case 3:
523
558
  attachments.push(mapImageUploadToAttachment(_image));
524
- return _context4.abrupt("return", "continue");
559
+ return _context6.abrupt("return", "continue");
525
560
  case 5:
526
561
  if (!((!_image || _image.state === _utils2.FileState.UPLOAD_FAILED) && !enableOfflineSupport)) {
527
- _context4.next = 7;
562
+ _context6.next = 7;
528
563
  break;
529
564
  }
530
- return _context4.abrupt("return", "continue");
565
+ return _context6.abrupt("return", "continue");
531
566
  case 7:
532
567
  if (!(_image.state === _utils2.FileState.UPLOADING)) {
533
- _context4.next = 14;
568
+ _context6.next = 14;
534
569
  break;
535
570
  }
536
571
  if (!value.sendImageAsync) {
537
- _context4.next = 12;
572
+ _context6.next = 12;
538
573
  break;
539
574
  }
540
575
  setAsyncIds(function (prevAsyncIds) {
541
576
  return [].concat((0, _toConsumableArray2["default"])(prevAsyncIds), [_image.id]);
542
577
  });
543
- _context4.next = 14;
578
+ _context6.next = 14;
544
579
  break;
545
580
  case 12:
546
581
  sending.current = false;
547
- return _context4.abrupt("return", {
582
+ return _context6.abrupt("return", {
548
583
  v: setText(prevText)
549
584
  });
550
585
  case 14:
@@ -553,107 +588,107 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
553
588
  }
554
589
  case 15:
555
590
  case "end":
556
- return _context4.stop();
591
+ return _context6.stop();
557
592
  }
558
593
  }, _loop);
559
594
  });
560
595
  _iterator3 = _createForOfIteratorHelper(imageUploads);
561
- _context5.prev = 15;
596
+ _context7.prev = 15;
562
597
  _iterator3.s();
563
598
  case 17:
564
599
  if ((_step3 = _iterator3.n()).done) {
565
- _context5.next = 27;
600
+ _context7.next = 27;
566
601
  break;
567
602
  }
568
603
  _image = _step3.value;
569
- return _context5.delegateYield(_loop(_image), "t0", 20);
604
+ return _context7.delegateYield(_loop(_image), "t0", 20);
570
605
  case 20:
571
- _ret = _context5.t0;
606
+ _ret = _context7.t0;
572
607
  if (!(_ret === "continue")) {
573
- _context5.next = 23;
608
+ _context7.next = 23;
574
609
  break;
575
610
  }
576
- return _context5.abrupt("continue", 25);
611
+ return _context7.abrupt("continue", 25);
577
612
  case 23:
578
613
  if (!((0, _typeof2["default"])(_ret) === "object")) {
579
- _context5.next = 25;
614
+ _context7.next = 25;
580
615
  break;
581
616
  }
582
- return _context5.abrupt("return", _ret.v);
617
+ return _context7.abrupt("return", _ret.v);
583
618
  case 25:
584
- _context5.next = 17;
619
+ _context7.next = 17;
585
620
  break;
586
621
  case 27:
587
- _context5.next = 32;
622
+ _context7.next = 32;
588
623
  break;
589
624
  case 29:
590
- _context5.prev = 29;
591
- _context5.t1 = _context5["catch"](15);
592
- _iterator3.e(_context5.t1);
625
+ _context7.prev = 29;
626
+ _context7.t1 = _context7["catch"](15);
627
+ _iterator3.e(_context7.t1);
593
628
  case 32:
594
- _context5.prev = 32;
629
+ _context7.prev = 32;
595
630
  _iterator3.f();
596
- return _context5.finish(32);
631
+ return _context7.finish(32);
597
632
  case 35:
598
633
  _iterator4 = _createForOfIteratorHelper(fileUploads);
599
- _context5.prev = 36;
634
+ _context7.prev = 36;
600
635
  _iterator4.s();
601
636
  case 38:
602
637
  if ((_step4 = _iterator4.n()).done) {
603
- _context5.next = 53;
638
+ _context7.next = 53;
604
639
  break;
605
640
  }
606
641
  _file3 = _step4.value;
607
642
  if (!enableOfflineSupport) {
608
- _context5.next = 45;
643
+ _context7.next = 45;
609
644
  break;
610
645
  }
611
646
  if (!(_file3.state === _utils2.FileState.NOT_SUPPORTED)) {
612
- _context5.next = 43;
647
+ _context7.next = 43;
613
648
  break;
614
649
  }
615
- return _context5.abrupt("return");
650
+ return _context7.abrupt("return");
616
651
  case 43:
617
652
  attachments.push(mapFileUploadToAttachment(_file3));
618
- return _context5.abrupt("continue", 51);
653
+ return _context7.abrupt("continue", 51);
619
654
  case 45:
620
655
  if (!(!_file3 || _file3.state === _utils2.FileState.UPLOAD_FAILED)) {
621
- _context5.next = 47;
656
+ _context7.next = 47;
622
657
  break;
623
658
  }
624
- return _context5.abrupt("continue", 51);
659
+ return _context7.abrupt("continue", 51);
625
660
  case 47:
626
661
  if (!(_file3.state === _utils2.FileState.UPLOADING)) {
627
- _context5.next = 50;
662
+ _context7.next = 50;
628
663
  break;
629
664
  }
630
665
  sending.current = false;
631
- return _context5.abrupt("return");
666
+ return _context7.abrupt("return");
632
667
  case 50:
633
668
  if (_file3.state === _utils2.FileState.UPLOADED || _file3.state === _utils2.FileState.FINISHED) {
634
669
  attachments.push(mapFileUploadToAttachment(_file3));
635
670
  }
636
671
  case 51:
637
- _context5.next = 38;
672
+ _context7.next = 38;
638
673
  break;
639
674
  case 53:
640
- _context5.next = 58;
675
+ _context7.next = 58;
641
676
  break;
642
677
  case 55:
643
- _context5.prev = 55;
644
- _context5.t2 = _context5["catch"](36);
645
- _iterator4.e(_context5.t2);
678
+ _context7.prev = 55;
679
+ _context7.t2 = _context7["catch"](36);
680
+ _iterator4.e(_context7.t2);
646
681
  case 58:
647
- _context5.prev = 58;
682
+ _context7.prev = 58;
648
683
  _iterator4.f();
649
- return _context5.finish(58);
684
+ return _context7.finish(58);
650
685
  case 61:
651
686
  if (!(!prevText && attachments.length === 0)) {
652
- _context5.next = 64;
687
+ _context7.next = 64;
653
688
  break;
654
689
  }
655
690
  sending.current = false;
656
- return _context5.abrupt("return");
691
+ return _context7.abrupt("return");
657
692
  case 64:
658
693
  message = value.editing;
659
694
  if (message && message.type !== 'error') {
@@ -695,12 +730,12 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
695
730
  }
696
731
  case 66:
697
732
  case "end":
698
- return _context5.stop();
733
+ return _context7.stop();
699
734
  }
700
- }, _callee4, null, [[15, 29, 32, 35], [36, 55, 58, 61]]);
735
+ }, _callee6, null, [[15, 29, 32, 35], [36, 55, 58, 61]]);
701
736
  }));
702
737
  return function sendMessage() {
703
- return _ref5.apply(this, arguments);
738
+ return _ref7.apply(this, arguments);
704
739
  };
705
740
  }();
706
741
  var sendMessageAsync = function sendMessageAsync(id) {
@@ -767,16 +802,16 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
767
802
  };
768
803
  var triggerSettings = getTriggerSettings();
769
804
  var updateMessage = function () {
770
- var _ref7 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5() {
771
- return _regenerator["default"].wrap(function _callee5$(_context6) {
772
- while (1) switch (_context6.prev = _context6.next) {
805
+ var _ref9 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee7() {
806
+ return _regenerator["default"].wrap(function _callee7$(_context8) {
807
+ while (1) switch (_context8.prev = _context8.next) {
773
808
  case 0:
774
- _context6.prev = 0;
809
+ _context8.prev = 0;
775
810
  if (!value.editing) {
776
- _context6.next = 4;
811
+ _context8.next = 4;
777
812
  break;
778
813
  }
779
- _context6.next = 4;
814
+ _context8.next = 4;
780
815
  return client.updateMessage(Object.assign({}, value.editing, {
781
816
  quoted_message: undefined,
782
817
  text: giphyEnabled && giphyActive ? "/giphy ".concat(text) : text
@@ -784,20 +819,20 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
784
819
  case 4:
785
820
  value.clearEditingState();
786
821
  resetInput();
787
- _context6.next = 11;
822
+ _context8.next = 11;
788
823
  break;
789
824
  case 8:
790
- _context6.prev = 8;
791
- _context6.t0 = _context6["catch"](0);
792
- console.log(_context6.t0);
825
+ _context8.prev = 8;
826
+ _context8.t0 = _context8["catch"](0);
827
+ console.log(_context8.t0);
793
828
  case 11:
794
829
  case "end":
795
- return _context6.stop();
830
+ return _context8.stop();
796
831
  }
797
- }, _callee5, null, [[0, 8]]);
832
+ }, _callee7, null, [[0, 8]]);
798
833
  }));
799
834
  return function updateMessage() {
800
- return _ref7.apply(this, arguments);
835
+ return _ref9.apply(this, arguments);
801
836
  };
802
837
  }();
803
838
  var regexCondition = /File (extension \.\w{2,4}|type \S+) is not supported/;
@@ -838,51 +873,51 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
838
873
  }
839
874
  };
840
875
  var uploadFile = function () {
841
- var _ref9 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6(_ref8) {
876
+ var _ref11 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee8(_ref10) {
842
877
  var newFile, file, id, response, _file$mimeType, compressedUri, extraData;
843
- return _regenerator["default"].wrap(function _callee6$(_context7) {
844
- while (1) switch (_context7.prev = _context7.next) {
878
+ return _regenerator["default"].wrap(function _callee8$(_context9) {
879
+ while (1) switch (_context9.prev = _context9.next) {
845
880
  case 0:
846
- newFile = _ref8.newFile;
881
+ newFile = _ref10.newFile;
847
882
  file = newFile.file, id = newFile.id;
848
883
  setFileUploads(getUploadSetStateAction(id, _utils2.FileState.UPLOADING));
849
884
  response = {};
850
- _context7.prev = 4;
885
+ _context9.prev = 4;
851
886
  if (!value.doDocUploadRequest) {
852
- _context7.next = 11;
887
+ _context9.next = 11;
853
888
  break;
854
889
  }
855
- _context7.next = 8;
890
+ _context9.next = 8;
856
891
  return value.doDocUploadRequest(file, channel);
857
892
  case 8:
858
- response = _context7.sent;
859
- _context7.next = 26;
893
+ response = _context9.sent;
894
+ _context9.next = 26;
860
895
  break;
861
896
  case 11:
862
897
  if (!(channel && file.uri)) {
863
- _context7.next = 26;
898
+ _context9.next = 26;
864
899
  break;
865
900
  }
866
901
  uploadAbortControllerRef.current.set(file.name, client.createAbortControllerForNextRequest());
867
902
  if (!((_file$mimeType = file.mimeType) != null && _file$mimeType.includes('image'))) {
868
- _context7.next = 22;
903
+ _context9.next = 22;
869
904
  break;
870
905
  }
871
- _context7.next = 16;
906
+ _context9.next = 16;
872
907
  return (0, _compressImage.compressedImageURI)(file, value.compressImageQuality);
873
908
  case 16:
874
- compressedUri = _context7.sent;
875
- _context7.next = 19;
909
+ compressedUri = _context9.sent;
910
+ _context9.next = 19;
876
911
  return channel.sendFile(compressedUri, file.name, file.mimeType);
877
912
  case 19:
878
- response = _context7.sent;
879
- _context7.next = 25;
913
+ response = _context9.sent;
914
+ _context9.next = 25;
880
915
  break;
881
916
  case 22:
882
- _context7.next = 24;
917
+ _context9.next = 24;
883
918
  return channel.sendFile(file.uri, file.name, file.mimeType);
884
919
  case 24:
885
- response = _context7.sent;
920
+ response = _context9.sent;
886
921
  case 25:
887
922
  uploadAbortControllerRef.current["delete"](file.name);
888
923
  case 26:
@@ -891,70 +926,70 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
891
926
  url: response.file
892
927
  };
893
928
  setFileUploads(getUploadSetStateAction(id, _utils2.FileState.UPLOADED, extraData));
894
- _context7.next = 36;
929
+ _context9.next = 36;
895
930
  break;
896
931
  case 30:
897
- _context7.prev = 30;
898
- _context7.t0 = _context7["catch"](4);
899
- if (!(_context7.t0 instanceof Error && (_context7.t0.name === 'AbortError' || _context7.t0.name === 'CanceledError'))) {
900
- _context7.next = 35;
932
+ _context9.prev = 30;
933
+ _context9.t0 = _context9["catch"](4);
934
+ if (!(_context9.t0 instanceof Error && (_context9.t0.name === 'AbortError' || _context9.t0.name === 'CanceledError'))) {
935
+ _context9.next = 35;
901
936
  break;
902
937
  }
903
938
  uploadAbortControllerRef.current["delete"](file.name);
904
- return _context7.abrupt("return");
939
+ return _context9.abrupt("return");
905
940
  case 35:
906
- handleFileOrImageUploadError(_context7.t0, false, id);
941
+ handleFileOrImageUploadError(_context9.t0, false, id);
907
942
  case 36:
908
943
  case "end":
909
- return _context7.stop();
944
+ return _context9.stop();
910
945
  }
911
- }, _callee6, null, [[4, 30]]);
946
+ }, _callee8, null, [[4, 30]]);
912
947
  }));
913
- return function uploadFile(_x) {
914
- return _ref9.apply(this, arguments);
948
+ return function uploadFile(_x3) {
949
+ return _ref11.apply(this, arguments);
915
950
  };
916
951
  }();
917
952
  var uploadImage = function () {
918
- var _ref11 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee7(_ref10) {
953
+ var _ref13 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee9(_ref12) {
919
954
  var _file$name;
920
- var newImage, _ref12, file, id, response, uri, filename, compressedUri, contentType, newImageUploads;
921
- return _regenerator["default"].wrap(function _callee7$(_context8) {
922
- while (1) switch (_context8.prev = _context8.next) {
955
+ var newImage, _ref14, file, id, response, uri, filename, compressedUri, contentType, newImageUploads;
956
+ return _regenerator["default"].wrap(function _callee9$(_context10) {
957
+ while (1) switch (_context10.prev = _context10.next) {
923
958
  case 0:
924
- newImage = _ref10.newImage;
925
- _ref12 = newImage || {}, file = _ref12.file, id = _ref12.id;
959
+ newImage = _ref12.newImage;
960
+ _ref14 = newImage || {}, file = _ref14.file, id = _ref14.id;
926
961
  if (file) {
927
- _context8.next = 4;
962
+ _context10.next = 4;
928
963
  break;
929
964
  }
930
- return _context8.abrupt("return");
965
+ return _context10.abrupt("return");
931
966
  case 4:
932
967
  response = {};
933
968
  uri = file.uri || '';
934
969
  filename = (_file$name = file.name) != null ? _file$name : (0, _utils2.getFileNameFromPath)(uri);
935
- _context8.prev = 7;
936
- _context8.next = 10;
970
+ _context10.prev = 7;
971
+ _context10.next = 10;
937
972
  return (0, _compressImage.compressedImageURI)(file, value.compressImageQuality);
938
973
  case 10:
939
- compressedUri = _context8.sent;
974
+ compressedUri = _context10.sent;
940
975
  contentType = (0, _mimeTypes.lookup)(filename) || 'multipart/form-data';
941
976
  if (!value.doImageUploadRequest) {
942
- _context8.next = 18;
977
+ _context10.next = 18;
943
978
  break;
944
979
  }
945
- _context8.next = 15;
980
+ _context10.next = 15;
946
981
  return value.doImageUploadRequest(file, channel);
947
982
  case 15:
948
- response = _context8.sent;
949
- _context8.next = 29;
983
+ response = _context10.sent;
984
+ _context10.next = 29;
950
985
  break;
951
986
  case 18:
952
987
  if (!(compressedUri && channel)) {
953
- _context8.next = 29;
988
+ _context10.next = 29;
954
989
  break;
955
990
  }
956
991
  if (!value.sendImageAsync) {
957
- _context8.next = 24;
992
+ _context10.next = 24;
958
993
  break;
959
994
  }
960
995
  uploadAbortControllerRef.current.set(filename, client.createAbortControllerForNextRequest());
@@ -977,14 +1012,14 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
977
1012
  }, function () {
978
1013
  uploadAbortControllerRef.current["delete"](filename);
979
1014
  });
980
- _context8.next = 29;
1015
+ _context10.next = 29;
981
1016
  break;
982
1017
  case 24:
983
1018
  uploadAbortControllerRef.current.set(filename, client.createAbortControllerForNextRequest());
984
- _context8.next = 27;
1019
+ _context10.next = 27;
985
1020
  return channel.sendImage(compressedUri, filename, contentType);
986
1021
  case 27:
987
- response = _context8.sent;
1022
+ response = _context10.sent;
988
1023
  uploadAbortControllerRef.current["delete"](filename);
989
1024
  case 29:
990
1025
  if (Object.keys(response).length) {
@@ -995,37 +1030,37 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
995
1030
  });
996
1031
  setImageUploads(newImageUploads);
997
1032
  }
998
- _context8.next = 38;
1033
+ _context10.next = 38;
999
1034
  break;
1000
1035
  case 32:
1001
- _context8.prev = 32;
1002
- _context8.t0 = _context8["catch"](7);
1003
- if (!(_context8.t0 instanceof Error && (_context8.t0.name === 'AbortError' || _context8.t0.name === 'CanceledError'))) {
1004
- _context8.next = 37;
1036
+ _context10.prev = 32;
1037
+ _context10.t0 = _context10["catch"](7);
1038
+ if (!(_context10.t0 instanceof Error && (_context10.t0.name === 'AbortError' || _context10.t0.name === 'CanceledError'))) {
1039
+ _context10.next = 37;
1005
1040
  break;
1006
1041
  }
1007
1042
  uploadAbortControllerRef.current["delete"](filename);
1008
- return _context8.abrupt("return");
1043
+ return _context10.abrupt("return");
1009
1044
  case 37:
1010
- handleFileOrImageUploadError(_context8.t0, true, id);
1045
+ handleFileOrImageUploadError(_context10.t0, true, id);
1011
1046
  case 38:
1012
1047
  case "end":
1013
- return _context8.stop();
1048
+ return _context10.stop();
1014
1049
  }
1015
- }, _callee7, null, [[7, 32]]);
1050
+ }, _callee9, null, [[7, 32]]);
1016
1051
  }));
1017
- return function uploadImage(_x2) {
1018
- return _ref11.apply(this, arguments);
1052
+ return function uploadImage(_x4) {
1053
+ return _ref13.apply(this, arguments);
1019
1054
  };
1020
1055
  }();
1021
1056
  var uploadNewFile = function () {
1022
- var _ref13 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee8(file) {
1023
- var _file$mimeType2;
1024
- var id, fileConfig, size_limit, isAllowed, sizeLimit, fileState, fileType, newFile;
1025
- return _regenerator["default"].wrap(function _callee8$(_context9) {
1026
- while (1) switch (_context9.prev = _context9.next) {
1057
+ var _ref15 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee10(file) {
1058
+ var _file$mimeType2, _id, fileConfig, size_limit, isAllowed, sizeLimit, fileState, fileType, newFile;
1059
+ return _regenerator["default"].wrap(function _callee10$(_context11) {
1060
+ while (1) switch (_context11.prev = _context11.next) {
1027
1061
  case 0:
1028
- id = (0, _utils2.generateRandomId)();
1062
+ _context11.prev = 0;
1063
+ _id = (0, _utils2.generateRandomId)();
1029
1064
  fileConfig = getFileUploadConfig();
1030
1065
  size_limit = fileConfig.size_limit;
1031
1066
  isAllowed = (0, _utils.isUploadAllowed)({
@@ -1034,7 +1069,7 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
1034
1069
  });
1035
1070
  sizeLimit = size_limit || _utils.MAX_FILE_SIZE_TO_UPLOAD;
1036
1071
  if (!(file.size && file.size > sizeLimit)) {
1037
- _context9.next = 9;
1072
+ _context11.next = 10;
1038
1073
  break;
1039
1074
  }
1040
1075
  _reactNative.Alert.alert(t('File is too large: {{ size }}, maximum upload size is {{ limit }}', {
@@ -1044,46 +1079,58 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
1044
1079
  setSelectedFiles(selectedFiles.filter(function (selectedFile) {
1045
1080
  return selectedFile.uri !== file.uri;
1046
1081
  }));
1047
- return _context9.abrupt("return");
1048
- case 9:
1082
+ return _context11.abrupt("return");
1083
+ case 10:
1049
1084
  fileState = isAllowed ? _utils2.FileState.UPLOADING : _utils2.FileState.NOT_SUPPORTED;
1050
1085
  fileType = file.type || ((_file$mimeType2 = file.mimeType) == null ? void 0 : _file$mimeType2.split('/')[0]);
1051
1086
  newFile = {
1052
1087
  duration: file.duration || 0,
1053
1088
  file: file,
1054
- id: file.id || id,
1089
+ id: file.id || _id,
1055
1090
  state: fileState,
1056
- type: fileType
1091
+ type: fileType,
1092
+ url: file.uri
1057
1093
  };
1058
- _context9.next = 14;
1094
+ _context11.next = 15;
1059
1095
  return Promise.all([setFileUploads(function (prevFileUploads) {
1060
1096
  return prevFileUploads.concat([newFile]);
1061
1097
  }), setNumberOfUploads(function (prevNumberOfUploads) {
1062
1098
  return prevNumberOfUploads + 1;
1063
1099
  })]);
1064
- case 14:
1065
- if (isAllowed) {
1066
- uploadFile({
1067
- newFile: newFile
1068
- });
1069
- }
1070
1100
  case 15:
1101
+ if (!isAllowed) {
1102
+ _context11.next = 18;
1103
+ break;
1104
+ }
1105
+ _context11.next = 18;
1106
+ return uploadFile({
1107
+ newFile: newFile
1108
+ });
1109
+ case 18:
1110
+ _context11.next = 23;
1111
+ break;
1112
+ case 20:
1113
+ _context11.prev = 20;
1114
+ _context11.t0 = _context11["catch"](0);
1115
+ console.log('Error uploading file', _context11.t0);
1116
+ case 23:
1071
1117
  case "end":
1072
- return _context9.stop();
1118
+ return _context11.stop();
1073
1119
  }
1074
- }, _callee8);
1120
+ }, _callee10, null, [[0, 20]]);
1075
1121
  }));
1076
- return function uploadNewFile(_x3) {
1077
- return _ref13.apply(this, arguments);
1122
+ return function uploadNewFile(_x5) {
1123
+ return _ref15.apply(this, arguments);
1078
1124
  };
1079
1125
  }();
1080
1126
  var uploadNewImage = function () {
1081
- var _ref14 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee9(image) {
1082
- var id, imageUploadConfig, size_limit, isAllowed, sizeLimit, imageState, newImage;
1083
- return _regenerator["default"].wrap(function _callee9$(_context10) {
1084
- while (1) switch (_context10.prev = _context10.next) {
1127
+ var _ref16 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee11(image) {
1128
+ var _id2, imageUploadConfig, size_limit, isAllowed, sizeLimit, imageState, newImage;
1129
+ return _regenerator["default"].wrap(function _callee11$(_context12) {
1130
+ while (1) switch (_context12.prev = _context12.next) {
1085
1131
  case 0:
1086
- id = (0, _utils2.generateRandomId)();
1132
+ _context12.prev = 0;
1133
+ _id2 = (0, _utils2.generateRandomId)();
1087
1134
  imageUploadConfig = getImageUploadConfig();
1088
1135
  size_limit = imageUploadConfig.size_limit;
1089
1136
  isAllowed = (0, _utils.isUploadAllowed)({
@@ -1092,7 +1139,7 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
1092
1139
  });
1093
1140
  sizeLimit = size_limit || _utils.MAX_FILE_SIZE_TO_UPLOAD;
1094
1141
  if (!(image.size && (image == null ? void 0 : image.size) > sizeLimit)) {
1095
- _context10.next = 9;
1142
+ _context12.next = 10;
1096
1143
  break;
1097
1144
  }
1098
1145
  _reactNative.Alert.alert(t('File is too large: {{ size }}, maximum upload size is {{ limit }}', {
@@ -1102,37 +1149,47 @@ var MessageInputProvider = function MessageInputProvider(_ref) {
1102
1149
  setSelectedImages(selectedImages.filter(function (selectedImage) {
1103
1150
  return selectedImage.uri !== image.uri;
1104
1151
  }));
1105
- return _context10.abrupt("return");
1106
- case 9:
1152
+ return _context12.abrupt("return");
1153
+ case 10:
1107
1154
  imageState = isAllowed ? _utils2.FileState.UPLOADING : _utils2.FileState.NOT_SUPPORTED;
1108
1155
  newImage = {
1109
1156
  file: image,
1110
1157
  height: image.height,
1111
- id: id,
1158
+ id: _id2,
1112
1159
  state: imageState,
1113
1160
  url: image.uri,
1114
1161
  width: image.width
1115
1162
  };
1116
- _context10.next = 13;
1163
+ _context12.next = 14;
1117
1164
  return Promise.all([setImageUploads(function (prevImageUploads) {
1118
1165
  return prevImageUploads.concat([newImage]);
1119
1166
  }), setNumberOfUploads(function (prevNumberOfUploads) {
1120
1167
  return prevNumberOfUploads + 1;
1121
1168
  })]);
1122
- case 13:
1123
- if (isAllowed) {
1124
- uploadImage({
1125
- newImage: newImage
1126
- });
1127
- }
1128
1169
  case 14:
1170
+ if (!isAllowed) {
1171
+ _context12.next = 17;
1172
+ break;
1173
+ }
1174
+ _context12.next = 17;
1175
+ return uploadImage({
1176
+ newImage: newImage
1177
+ });
1178
+ case 17:
1179
+ _context12.next = 22;
1180
+ break;
1181
+ case 19:
1182
+ _context12.prev = 19;
1183
+ _context12.t0 = _context12["catch"](0);
1184
+ console.log('Error uploading image', _context12.t0);
1185
+ case 22:
1129
1186
  case "end":
1130
- return _context10.stop();
1187
+ return _context12.stop();
1131
1188
  }
1132
- }, _callee9);
1189
+ }, _callee11, null, [[0, 19]]);
1133
1190
  }));
1134
- return function uploadNewImage(_x4) {
1135
- return _ref14.apply(this, arguments);
1191
+ return function uploadNewImage(_x6) {
1192
+ return _ref16.apply(this, arguments);
1136
1193
  };
1137
1194
  }();
1138
1195
  var messageInputContext = (0, _useCreateMessageInputContext.useCreateMessageInputContext)(Object.assign({