sceyt-chat-react-uikit 1.7.2-beta.1 → 1.7.2-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.
package/index.js CHANGED
@@ -10348,7 +10348,9 @@ var initialState$1 = {
10348
10348
  openedMessageMenu: '',
10349
10349
  attachmentsUploadingProgress: {},
10350
10350
  playingAudioId: null,
10351
- selectedMessagesMap: null
10351
+ selectedMessagesMap: null,
10352
+ oGMetadata: {},
10353
+ attachmentUpdatedMap: {}
10352
10354
  };
10353
10355
  var messageSlice = createSlice({
10354
10356
  name: 'messages',
@@ -10477,39 +10479,8 @@ var messageSlice = createSlice({
10477
10479
  updateMessageAttachment: function updateMessageAttachment(state, action) {
10478
10480
  var _action$payload4 = action.payload,
10479
10481
  url = _action$payload4.url,
10480
- messageId = _action$payload4.messageId,
10481
- params = _action$payload4.params;
10482
- state.activeChannelMessages = state.activeChannelMessages.map(function (message) {
10483
- if (message.id === messageId) {
10484
- for (var index = 0; index < message.attachments.length; index++) {
10485
- var attachment = message.attachments[index];
10486
- if (attachment.url === url) {
10487
- message.attachments[index] = _extends({}, attachment, params);
10488
- }
10489
- }
10490
- }
10491
- if (message.attachments.length) {
10492
- var detachedAttachments = message.attachments.map(function (att) {
10493
- var _att$user, _att$user2;
10494
- return _extends({}, att, {
10495
- user: _extends({}, att.user, {
10496
- metadata: _extends({}, ((_att$user = att.user) === null || _att$user === void 0 ? void 0 : _att$user.metadata) || {}),
10497
- presence: _extends({}, ((_att$user2 = att.user) === null || _att$user2 === void 0 ? void 0 : _att$user2.presence) || {})
10498
- })
10499
- });
10500
- });
10501
- updateMessageOnAllMessages(messageId, {
10502
- attachments: detachedAttachments
10503
- });
10504
- updateMessageOnMap(message.channelId, {
10505
- messageId: messageId,
10506
- params: {
10507
- attachments: detachedAttachments
10508
- }
10509
- });
10510
- }
10511
- return message;
10512
- });
10482
+ attachmentUrl = _action$payload4.attachmentUrl;
10483
+ state.attachmentUpdatedMap[url] = attachmentUrl;
10513
10484
  },
10514
10485
  addReactionToMessage: function addReactionToMessage(state, action) {
10515
10486
  var _action$payload5 = action.payload,
@@ -10691,6 +10662,21 @@ var messageSlice = createSlice({
10691
10662
  },
10692
10663
  clearSelectedMessages: function clearSelectedMessages(state) {
10693
10664
  state.selectedMessagesMap = null;
10665
+ },
10666
+ setOGMetadata: function setOGMetadata(state, action) {
10667
+ var _action$payload10 = action.payload,
10668
+ url = _action$payload10.url,
10669
+ metadata = _action$payload10.metadata;
10670
+ state.oGMetadata[url] = metadata;
10671
+ },
10672
+ updateOGMetadata: function updateOGMetadata(state, action) {
10673
+ var _action$payload11 = action.payload,
10674
+ url = _action$payload11.url,
10675
+ metadata = _action$payload11.metadata;
10676
+ if (metadata) {
10677
+ var existing = state.oGMetadata[url];
10678
+ state.oGMetadata[url] = existing ? _extends({}, existing, metadata) : metadata;
10679
+ }
10694
10680
  }
10695
10681
  },
10696
10682
  extraReducers: function extraReducers(builder) {
@@ -10740,7 +10726,9 @@ var _messageSlice$actions = messageSlice.actions,
10740
10726
  setPlayingAudioId = _messageSlice$actions.setPlayingAudioId,
10741
10727
  addSelectedMessage = _messageSlice$actions.addSelectedMessage,
10742
10728
  removeSelectedMessage = _messageSlice$actions.removeSelectedMessage,
10743
- clearSelectedMessages = _messageSlice$actions.clearSelectedMessages;
10729
+ clearSelectedMessages = _messageSlice$actions.clearSelectedMessages,
10730
+ setOGMetadata = _messageSlice$actions.setOGMetadata,
10731
+ updateOGMetadata = _messageSlice$actions.updateOGMetadata;
10744
10732
  var MessageReducer = messageSlice.reducer;
10745
10733
 
10746
10734
  var initialState$2 = {
@@ -11820,11 +11808,22 @@ function setMessagesHasNextAC(hasNext) {
11820
11808
  hasNext: hasNext
11821
11809
  });
11822
11810
  }
11823
- function setUpdateMessageAttachmentAC(url, messageId, params) {
11811
+ function setOGMetadataAC(url, metadata) {
11812
+ return setOGMetadata({
11813
+ url: url,
11814
+ metadata: metadata
11815
+ });
11816
+ }
11817
+ function updateOGMetadataAC(url, metadata) {
11818
+ return updateOGMetadata({
11819
+ url: url,
11820
+ metadata: metadata
11821
+ });
11822
+ }
11823
+ function setUpdateMessageAttachmentAC(url, attachmentUrl) {
11824
11824
  return updateMessageAttachment({
11825
11825
  url: url,
11826
- messageId: messageId,
11827
- params: params
11826
+ attachmentUrl: attachmentUrl
11828
11827
  });
11829
11828
  }
11830
11829
  function updateMessageAC(messageId, params, addIfNotExists) {
@@ -17135,6 +17134,9 @@ var playingAudioIdSelector = function playingAudioIdSelector(store) {
17135
17134
  var selectedMessagesMapSelector = function selectedMessagesMapSelector(store) {
17136
17135
  return store.MessageReducer.selectedMessagesMap;
17137
17136
  };
17137
+ var attachmentUpdatedMapSelector = function attachmentUpdatedMapSelector(store) {
17138
+ return store.MessageReducer.attachmentUpdatedMap;
17139
+ };
17138
17140
 
17139
17141
  var getFrame = function getFrame(videoSrc, time) {
17140
17142
  try {
@@ -29595,13 +29597,17 @@ var Attachment = function Attachment(_ref) {
29595
29597
  var connectionStatus = useSelector(connectionStatusSelector);
29596
29598
  var theme = useSelector(themeSelector);
29597
29599
  var imageContRef = React.useRef(null);
29598
- var _useState = React.useState(!attachment.attachmentUrl),
29600
+ var attachmentUpdatedMap = useSelector(attachmentUpdatedMapSelector) || {};
29601
+ var attachmentUrlFromMap = React.useMemo(function () {
29602
+ return attachmentUpdatedMap[attachment.url];
29603
+ }, [attachmentUpdatedMap, attachment.url]);
29604
+ var _useState = React.useState(!attachmentUrlFromMap),
29599
29605
  imageLoading = _useState[0],
29600
29606
  setImageLoading = _useState[1];
29601
29607
  var _useState2 = React.useState(false),
29602
29608
  downloadingFile = _useState2[0],
29603
29609
  setDownloadingFile = _useState2[1];
29604
- var _useState3 = React.useState(''),
29610
+ var _useState3 = React.useState(attachmentUrlFromMap),
29605
29611
  attachmentUrl = _useState3[0],
29606
29612
  setAttachmentUrl = _useState3[1];
29607
29613
  var _useState4 = React.useState(),
@@ -29625,27 +29631,26 @@ var Attachment = function Attachment(_ref) {
29625
29631
  var fileNameRef = React.useRef(null);
29626
29632
  var customDownloader = getCustomDownloader();
29627
29633
  var previewFileType = isPreview && attachment.data.type.split('/')[0];
29634
+ var attachmentMetadata = React.useMemo(function () {
29635
+ return isJSON(attachment.metadata) ? JSON.parse(attachment.metadata) : attachment.metadata;
29636
+ }, [attachment.metadata]);
29628
29637
  var _useMemo = React.useMemo(function () {
29629
29638
  var attachmentData = null;
29630
- if (attachment.metadata && typeof attachment.metadata === 'string') {
29631
- attachmentData = isJSON(attachment.metadata) ? JSON.parse(attachment.metadata) : attachment.metadata;
29632
- } else if (attachment.metadata && attachment.metadata.szw && attachment.metadata.szh) {
29633
- attachmentData = attachment.metadata;
29634
- }
29639
+ attachmentData = attachmentMetadata;
29635
29640
  return attachmentData && attachmentData.szw && attachmentData.szh ? calculateRenderedImageWidth(attachmentData.szw, attachmentData.szh, attachment.type === attachmentTypes.image ? imageAttachmentMaxWidth : videoAttachmentMaxWidth, attachment.type === attachmentTypes.image ? imageAttachmentMaxHeight || 400 : videoAttachmentMaxHeight) : [];
29636
- }, []),
29641
+ }, [attachmentMetadata]),
29637
29642
  renderWidth = _useMemo[0],
29638
29643
  renderHeight = _useMemo[1];
29639
29644
  var isInUploadingState = attachmentCompilationState[attachment.tid] && (attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING || attachmentCompilationState[attachment.tid] === UPLOAD_STATE.PAUSED);
29640
29645
  var attachmentThumb;
29641
29646
  var withPrefix = true;
29642
- if (attachment.type !== attachmentTypes.voice && attachment.type !== attachmentTypes.link && attachment.metadata && attachment.metadata.tmb) {
29647
+ if (attachment.type !== attachmentTypes.voice && attachment.type !== attachmentTypes.link && attachmentMetadata && attachmentMetadata.tmb) {
29643
29648
  try {
29644
- if (attachment.metadata.tmb.length < 70) {
29645
- attachmentThumb = base64ToToDataURL(attachment.metadata.tmb);
29649
+ if (attachmentMetadata.tmb.length < 70) {
29650
+ attachmentThumb = base64ToToDataURL(attachmentMetadata.tmb);
29646
29651
  withPrefix = false;
29647
29652
  } else {
29648
- attachmentThumb = attachment.metadata && attachment.metadata.tmb;
29653
+ attachmentThumb = attachmentMetadata && attachmentMetadata.tmb;
29649
29654
  }
29650
29655
  } catch (e) {
29651
29656
  log.error('error on get attachmentThumb', e);
@@ -29809,9 +29814,7 @@ var Attachment = function Attachment(_ref) {
29809
29814
  if (attachment.type === attachmentTypes.image && !isPreview) {
29810
29815
  if (cachedUrl) {
29811
29816
  setAttachmentUrl(cachedUrl);
29812
- dispatch(setUpdateMessageAttachmentAC(attachment.url, attachment.messageId, {
29813
- attachmentUrl: cachedUrl
29814
- }));
29817
+ dispatch(setUpdateMessageAttachmentAC(attachment.url, cachedUrl));
29815
29818
  setIsCached(true);
29816
29819
  } else {
29817
29820
  setIsCached(false);
@@ -31384,54 +31387,95 @@ var validateUrl = function validateUrl(url) {
31384
31387
  }
31385
31388
  };
31386
31389
  var OGMetadata = function OGMetadata(_ref) {
31387
- var _metadata$og6, _metadata$og6$image, _metadata$og6$image$, _metadata$og7, _metadata$og7$image, _metadata$og7$image$, _metadata$og8, _metadata$og8$image, _metadata$og8$image$, _metadata$og9, _metadata$og0, _metadata$og0$favicon, _metadata$og1, _metadata$og1$favicon, _metadata$og10, _metadata$og11, _metadata$og12;
31390
+ var _metadata$og4, _metadata$og4$image, _metadata$og4$image$, _metadata$og5, _metadata$og5$image, _metadata$og5$image$, _metadata$og6, _metadata$og7, _metadata$og7$favicon, _metadata$og8, _metadata$og8$favicon, _metadata$og9, _metadata$og0, _metadata$og1;
31388
31391
  var attachments = _ref.attachments,
31389
31392
  state = _ref.state;
31390
- var _useState = React.useState(null),
31391
- metadata = _useState[0],
31392
- setMetadata = _useState[1];
31393
- var _useState2 = React.useState(true),
31394
- imageLoadError = _useState2[0],
31395
- setImageLoadError = _useState2[1];
31396
- var _useState3 = React.useState(true),
31397
- faviconLoadError = _useState3[0],
31398
- setFaviconLoadError = _useState3[1];
31399
- var _useState4 = React.useState(false),
31400
- imageLoaded = _useState4[0],
31401
- setImageLoaded = _useState4[1];
31402
- var _useState5 = React.useState(0),
31403
- imageWidth = _useState5[0],
31404
- setImageWidth = _useState5[1];
31405
- var _useState6 = React.useState(0),
31406
- imageHeight = _useState6[0],
31407
- setImageHeight = _useState6[1];
31393
+ var dispatch = useDispatch();
31394
+ var oGMetadata = useSelector(function (state) {
31395
+ return state.MessageReducer.oGMetadata;
31396
+ });
31408
31397
  var attachment = React.useMemo(function () {
31409
31398
  return attachments.find(function (attachment) {
31410
31399
  return attachment.type === attachmentTypes.link;
31411
31400
  });
31412
31401
  }, [attachments]);
31402
+ var metadata = React.useMemo(function () {
31403
+ return oGMetadata[attachment === null || attachment === void 0 ? void 0 : attachment.url] || null;
31404
+ }, [oGMetadata, attachment === null || attachment === void 0 ? void 0 : attachment.url]);
31405
+ var _useState = React.useState(false),
31406
+ imageLoadError = _useState[0],
31407
+ setImageLoadError = _useState[1];
31408
+ var _useState2 = React.useState(false),
31409
+ faviconLoadError = _useState2[0],
31410
+ setFaviconLoadError = _useState2[1];
31411
+ var _useState3 = React.useState(false),
31412
+ shouldAnimate = _useState3[0],
31413
+ setShouldAnimate = _useState3[1];
31414
+ var handleMetadata = React.useCallback(function (metadata) {
31415
+ if (metadata) {
31416
+ dispatch(setOGMetadataAC(attachment === null || attachment === void 0 ? void 0 : attachment.url, metadata));
31417
+ } else {
31418
+ dispatch(setOGMetadataAC(attachment === null || attachment === void 0 ? void 0 : attachment.url, null));
31419
+ }
31420
+ }, []);
31413
31421
  var ogMetadataQueryBuilder = React.useCallback(function (url) {
31414
31422
  try {
31415
31423
  var client = getClient();
31416
- var _temp2 = function () {
31424
+ var _temp3 = function () {
31417
31425
  if (client) {
31418
- var _temp = _catch(function () {
31426
+ var _temp2 = _catch(function () {
31419
31427
  var queryBuilder = new client.MessageLinkOGQueryBuilder(url);
31420
31428
  return Promise.resolve(queryBuilder.build()).then(function (query) {
31421
31429
  return Promise.resolve(query.loadOGData()).then(function (metadata) {
31422
- return Promise.resolve(storeMetadata(url, metadata)).then(function () {
31423
- setMetadata(metadata);
31424
- });
31430
+ var _metadata$og, _metadata$og$image, _metadata$og$image$;
31431
+ var image = new Image();
31432
+ image.src = metadata === null || metadata === void 0 ? void 0 : (_metadata$og = metadata.og) === null || _metadata$og === void 0 ? void 0 : (_metadata$og$image = _metadata$og.image) === null || _metadata$og$image === void 0 ? void 0 : (_metadata$og$image$ = _metadata$og$image[0]) === null || _metadata$og$image$ === void 0 ? void 0 : _metadata$og$image$.url;
31433
+ var _temp = function () {
31434
+ if (image.src) {
31435
+ image.onload = function () {
31436
+ try {
31437
+ var imageWidth = image.width;
31438
+ var imageHeight = image.height;
31439
+ return Promise.resolve(storeMetadata(url, _extends({}, metadata, {
31440
+ imageWidth: imageWidth,
31441
+ imageHeight: imageHeight
31442
+ }))).then(function () {
31443
+ handleMetadata(_extends({}, metadata, {
31444
+ imageWidth: imageWidth,
31445
+ imageHeight: imageHeight
31446
+ }));
31447
+ });
31448
+ } catch (e) {
31449
+ return Promise.reject(e);
31450
+ }
31451
+ };
31452
+ image.onerror = function () {
31453
+ try {
31454
+ setImageLoadError(true);
31455
+ return Promise.resolve(storeMetadata(url, _extends({}, metadata))).then(function () {
31456
+ handleMetadata(_extends({}, metadata));
31457
+ });
31458
+ } catch (e) {
31459
+ return Promise.reject(e);
31460
+ }
31461
+ };
31462
+ } else {
31463
+ return Promise.resolve(storeMetadata(url, _extends({}, metadata))).then(function () {
31464
+ handleMetadata(_extends({}, metadata));
31465
+ });
31466
+ }
31467
+ }();
31468
+ if (_temp && _temp.then) return _temp.then(function () {});
31425
31469
  });
31426
31470
  });
31427
31471
  }, function () {
31428
31472
  console.log('Failed to fetch OG metadata');
31429
- setMetadata(null);
31473
+ handleMetadata(null);
31430
31474
  });
31431
- if (_temp && _temp.then) return _temp.then(function () {});
31475
+ if (_temp2 && _temp2.then) return _temp2.then(function () {});
31432
31476
  }
31433
31477
  }();
31434
- return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {
31478
+ return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {
31435
31479
  return null;
31436
31480
  }) : null);
31437
31481
  } catch (e) {
@@ -31439,16 +31483,16 @@ var OGMetadata = function OGMetadata(_ref) {
31439
31483
  }
31440
31484
  }, []);
31441
31485
  React.useEffect(function () {
31442
- if (attachment !== null && attachment !== void 0 && attachment.id && attachment !== null && attachment !== void 0 && attachment.url) {
31486
+ if (attachment !== null && attachment !== void 0 && attachment.id && attachment !== null && attachment !== void 0 && attachment.url && !metadata) {
31487
+ setShouldAnimate(true);
31443
31488
  var url = attachment === null || attachment === void 0 ? void 0 : attachment.url;
31444
31489
  if (url) {
31445
31490
  getMetadata(url).then(function (cachedMetadata) {
31446
31491
  try {
31447
31492
  if (cachedMetadata) {
31448
- setMetadata(cachedMetadata);
31449
- } else {
31450
- ogMetadataQueryBuilder(url);
31493
+ handleMetadata(cachedMetadata);
31451
31494
  }
31495
+ ogMetadataQueryBuilder(url);
31452
31496
  return Promise.resolve();
31453
31497
  } catch (e) {
31454
31498
  return Promise.reject(e);
@@ -31458,7 +31502,7 @@ var OGMetadata = function OGMetadata(_ref) {
31458
31502
  });
31459
31503
  }
31460
31504
  }
31461
- }, [attachment === null || attachment === void 0 ? void 0 : attachment.url]);
31505
+ }, [attachment === null || attachment === void 0 ? void 0 : attachment.url, metadata]);
31462
31506
  var ogUrl = React.useMemo(function () {
31463
31507
  var url = attachment === null || attachment === void 0 ? void 0 : attachment.url;
31464
31508
  var urlObj = validateUrl(url);
@@ -31468,102 +31512,126 @@ var OGMetadata = function OGMetadata(_ref) {
31468
31512
  return url;
31469
31513
  }, [attachment === null || attachment === void 0 ? void 0 : attachment.url]);
31470
31514
  var showOGMetadata = React.useMemo(function () {
31471
- var _metadata$og, _metadata$og2, _metadata$og2$image, _metadata$og2$image$, _metadata$og3;
31472
- return state !== 'deleted' && (metadata === null || metadata === void 0 ? void 0 : (_metadata$og = metadata.og) === null || _metadata$og === void 0 ? void 0 : _metadata$og.title) && (metadata === null || metadata === void 0 ? void 0 : (_metadata$og2 = metadata.og) === null || _metadata$og2 === void 0 ? void 0 : (_metadata$og2$image = _metadata$og2.image) === null || _metadata$og2$image === void 0 ? void 0 : (_metadata$og2$image$ = _metadata$og2$image[0]) === null || _metadata$og2$image$ === void 0 ? void 0 : _metadata$og2$image$.url) && (metadata === null || metadata === void 0 ? void 0 : (_metadata$og3 = metadata.og) === null || _metadata$og3 === void 0 ? void 0 : _metadata$og3.description) && metadata;
31515
+ var _metadata$og2, _metadata$og3;
31516
+ return state !== 'deleted' && (metadata === null || metadata === void 0 ? void 0 : (_metadata$og2 = metadata.og) === null || _metadata$og2 === void 0 ? void 0 : _metadata$og2.title) && (metadata === null || metadata === void 0 ? void 0 : (_metadata$og3 = metadata.og) === null || _metadata$og3 === void 0 ? void 0 : _metadata$og3.description) && metadata;
31473
31517
  }, [state, metadata]);
31474
- React.useEffect(function () {
31475
- var _metadata$og4, _metadata$og4$image, _metadata$og4$image$;
31476
- if (metadata !== null && metadata !== void 0 && (_metadata$og4 = metadata.og) !== null && _metadata$og4 !== void 0 && (_metadata$og4$image = _metadata$og4.image) !== null && _metadata$og4$image !== void 0 && (_metadata$og4$image$ = _metadata$og4$image[0]) !== null && _metadata$og4$image$ !== void 0 && _metadata$og4$image$.url) {
31477
- var _metadata$og5, _metadata$og5$image, _metadata$og5$image$;
31478
- var image = new Image();
31479
- image.src = metadata === null || metadata === void 0 ? void 0 : (_metadata$og5 = metadata.og) === null || _metadata$og5 === void 0 ? void 0 : (_metadata$og5$image = _metadata$og5.image) === null || _metadata$og5$image === void 0 ? void 0 : (_metadata$og5$image$ = _metadata$og5$image[0]) === null || _metadata$og5$image$ === void 0 ? void 0 : _metadata$og5$image$.url;
31480
- image.onload = function () {
31481
- var imageWidth = image.width;
31482
- var imageHeight = image.height;
31483
- setImageWidth(imageWidth);
31484
- setImageHeight(imageHeight);
31485
- setImageLoadError(false);
31486
- setImageLoaded(true);
31487
- };
31488
- image.onerror = function () {
31489
- setImageLoadError(true);
31490
- setImageLoaded(true);
31491
- };
31492
- }
31493
- }, [metadata === null || metadata === void 0 ? void 0 : (_metadata$og6 = metadata.og) === null || _metadata$og6 === void 0 ? void 0 : (_metadata$og6$image = _metadata$og6.image) === null || _metadata$og6$image === void 0 ? void 0 : (_metadata$og6$image$ = _metadata$og6$image[0]) === null || _metadata$og6$image$ === void 0 ? void 0 : _metadata$og6$image$.url]);
31494
31518
  var calculatedImageHeight = React.useMemo(function () {
31495
- return imageHeight / (imageWidth / 400);
31496
- }, [imageWidth, imageHeight]);
31519
+ if (!(metadata !== null && metadata !== void 0 && metadata.imageWidth)) {
31520
+ return 0;
31521
+ }
31522
+ return (metadata === null || metadata === void 0 ? void 0 : metadata.imageHeight) / ((metadata === null || metadata === void 0 ? void 0 : metadata.imageWidth) / 400);
31523
+ }, [metadata === null || metadata === void 0 ? void 0 : metadata.imageWidth, metadata === null || metadata === void 0 ? void 0 : metadata.imageHeight]);
31497
31524
  return /*#__PURE__*/React__default.createElement(OGMetadataContainer, {
31498
31525
  showOGMetadata: !!showOGMetadata
31499
31526
  }, /*#__PURE__*/React__default.createElement("div", {
31500
31527
  onClick: function onClick() {
31501
31528
  window.open(attachment === null || attachment === void 0 ? void 0 : attachment.url, '_blank');
31529
+ },
31530
+ style: {
31531
+ width: showOGMetadata ? '400px' : 'auto'
31502
31532
  }
31503
31533
  }, /*#__PURE__*/React__default.createElement(ImageContainer, {
31504
- showOGMetadata: !!showOGMetadata && !imageLoadError && imageLoaded,
31505
- width: 400,
31506
- height: calculatedImageHeight
31507
- }, metadata !== null && metadata !== void 0 && (_metadata$og7 = metadata.og) !== null && _metadata$og7 !== void 0 && (_metadata$og7$image = _metadata$og7.image) !== null && _metadata$og7$image !== void 0 && (_metadata$og7$image$ = _metadata$og7$image[0]) !== null && _metadata$og7$image$ !== void 0 && _metadata$og7$image$.url && !imageLoadError ? (/*#__PURE__*/React__default.createElement(Img, {
31508
- src: metadata === null || metadata === void 0 ? void 0 : (_metadata$og8 = metadata.og) === null || _metadata$og8 === void 0 ? void 0 : (_metadata$og8$image = _metadata$og8.image) === null || _metadata$og8$image === void 0 ? void 0 : (_metadata$og8$image$ = _metadata$og8$image[0]) === null || _metadata$og8$image$ === void 0 ? void 0 : _metadata$og8$image$.url,
31534
+ showOGMetadata: !!showOGMetadata && !imageLoadError,
31535
+ containerWidth: 400,
31536
+ containerHeight: calculatedImageHeight,
31537
+ shouldAnimate: shouldAnimate
31538
+ }, metadata !== null && metadata !== void 0 && (_metadata$og4 = metadata.og) !== null && _metadata$og4 !== void 0 && (_metadata$og4$image = _metadata$og4.image) !== null && _metadata$og4$image !== void 0 && (_metadata$og4$image$ = _metadata$og4$image[0]) !== null && _metadata$og4$image$ !== void 0 && _metadata$og4$image$.url && !imageLoadError ? (/*#__PURE__*/React__default.createElement(Img, {
31539
+ src: metadata === null || metadata === void 0 ? void 0 : (_metadata$og5 = metadata.og) === null || _metadata$og5 === void 0 ? void 0 : (_metadata$og5$image = _metadata$og5.image) === null || _metadata$og5$image === void 0 ? void 0 : (_metadata$og5$image$ = _metadata$og5$image[0]) === null || _metadata$og5$image$ === void 0 ? void 0 : _metadata$og5$image$.url,
31509
31540
  alt: 'OG metadata image',
31510
- width: 400,
31511
- height: calculatedImageHeight
31512
- })) : null), showOGMetadata && imageLoaded ? (/*#__PURE__*/React__default.createElement(OGText, null, /*#__PURE__*/React__default.createElement(Url, {
31513
- maxWidth: 400
31514
- }, ogUrl), metadata !== null && metadata !== void 0 && (_metadata$og9 = metadata.og) !== null && _metadata$og9 !== void 0 && _metadata$og9.title ? (/*#__PURE__*/React__default.createElement(Title, {
31515
- maxWidth: 400
31516
- }, metadata !== null && metadata !== void 0 && (_metadata$og0 = metadata.og) !== null && _metadata$og0 !== void 0 && (_metadata$og0$favicon = _metadata$og0.favicon) !== null && _metadata$og0$favicon !== void 0 && _metadata$og0$favicon.url && !faviconLoadError ? (/*#__PURE__*/React__default.createElement(Favicon, {
31517
- src: metadata === null || metadata === void 0 ? void 0 : (_metadata$og1 = metadata.og) === null || _metadata$og1 === void 0 ? void 0 : (_metadata$og1$favicon = _metadata$og1.favicon) === null || _metadata$og1$favicon === void 0 ? void 0 : _metadata$og1$favicon.url,
31541
+ imageWidth: 400,
31542
+ imageHeight: calculatedImageHeight,
31543
+ shouldAnimate: shouldAnimate
31544
+ })) : null), showOGMetadata ? (/*#__PURE__*/React__default.createElement(OGText, {
31545
+ shouldAnimate: shouldAnimate
31546
+ }, /*#__PURE__*/React__default.createElement(Url, {
31547
+ maxWidth: 400,
31548
+ shouldAnimate: shouldAnimate
31549
+ }, ogUrl), metadata !== null && metadata !== void 0 && (_metadata$og6 = metadata.og) !== null && _metadata$og6 !== void 0 && _metadata$og6.title ? (/*#__PURE__*/React__default.createElement(Title, {
31550
+ maxWidth: 400,
31551
+ shouldAnimate: shouldAnimate
31552
+ }, metadata !== null && metadata !== void 0 && (_metadata$og7 = metadata.og) !== null && _metadata$og7 !== void 0 && (_metadata$og7$favicon = _metadata$og7.favicon) !== null && _metadata$og7$favicon !== void 0 && _metadata$og7$favicon.url && !faviconLoadError ? (/*#__PURE__*/React__default.createElement(Favicon, {
31553
+ shouldAnimate: shouldAnimate,
31554
+ src: metadata === null || metadata === void 0 ? void 0 : (_metadata$og8 = metadata.og) === null || _metadata$og8 === void 0 ? void 0 : (_metadata$og8$favicon = _metadata$og8.favicon) === null || _metadata$og8$favicon === void 0 ? void 0 : _metadata$og8$favicon.url,
31518
31555
  onLoad: function onLoad() {
31519
31556
  return setFaviconLoadError(false);
31520
31557
  },
31521
31558
  onError: function onError() {
31522
- return setFaviconLoadError(true);
31559
+ dispatch(updateOGMetadataAC(attachment === null || attachment === void 0 ? void 0 : attachment.url, _extends({}, metadata, {
31560
+ og: _extends({}, metadata === null || metadata === void 0 ? void 0 : metadata.og, {
31561
+ favicon: {
31562
+ url: ''
31563
+ }
31564
+ })
31565
+ })));
31566
+ setFaviconLoadError(true);
31523
31567
  }
31524
- })) : null, /*#__PURE__*/React__default.createElement("span", null, metadata === null || metadata === void 0 ? void 0 : (_metadata$og10 = metadata.og) === null || _metadata$og10 === void 0 ? void 0 : _metadata$og10.title))) : null, metadata !== null && metadata !== void 0 && (_metadata$og11 = metadata.og) !== null && _metadata$og11 !== void 0 && _metadata$og11.description ? /*#__PURE__*/React__default.createElement(Desc, {
31525
- maxWidth: 400
31526
- }, metadata === null || metadata === void 0 ? void 0 : (_metadata$og12 = metadata.og) === null || _metadata$og12 === void 0 ? void 0 : _metadata$og12.description) : null)) : null));
31568
+ })) : null, /*#__PURE__*/React__default.createElement("span", null, metadata === null || metadata === void 0 ? void 0 : (_metadata$og9 = metadata.og) === null || _metadata$og9 === void 0 ? void 0 : _metadata$og9.title))) : null, metadata !== null && metadata !== void 0 && (_metadata$og0 = metadata.og) !== null && _metadata$og0 !== void 0 && _metadata$og0.description ? (/*#__PURE__*/React__default.createElement(Desc, {
31569
+ maxWidth: 400,
31570
+ shouldAnimate: shouldAnimate
31571
+ }, metadata === null || metadata === void 0 ? void 0 : (_metadata$og1 = metadata.og) === null || _metadata$og1 === void 0 ? void 0 : _metadata$og1.description)) : null)) : null));
31527
31572
  };
31528
31573
  var OGMetadataContainer = styled__default.div(_templateObject$A || (_templateObject$A = _taggedTemplateLiteralLoose(["\n min-width: inherit;\n max-width: inherit;\n display: grid;\n grid-template-columns: 1fr;\n background-color: rgba(0, 0, 0, 0.034);\n border-radius: 6px;\n margin-bottom: 0.4rem;\n margin: 0 auto;\n margin-bottom: ", ";\n &:hover {\n background-color: rgba(0, 0, 0, 0.1);\n cursor: pointer;\n }\n"])), function (_ref2) {
31529
31574
  var showOGMetadata = _ref2.showOGMetadata;
31530
31575
  return showOGMetadata ? '0.8rem' : '0';
31531
31576
  });
31532
- var ImageContainer = styled__default.div(_templateObject2$v || (_templateObject2$v = _taggedTemplateLiteralLoose(["\n ", "\n\n ", "\n\n opacity: ", ";\n overflow: hidden;\n margin: 0 auto;\n padding: ", ";\n transition: height 0.2s ease;\n"])), function (_ref3) {
31533
- var width = _ref3.width;
31534
- return width ? "\n max-width: " + (width + "px") + ";\n " : "\n max-width: 100%;\n width: 100%;\n ";
31577
+ var ImageContainer = styled__default.div(_templateObject2$v || (_templateObject2$v = _taggedTemplateLiteralLoose(["\n ", "\n\n ", "\n\n opacity: ", ";\n overflow: hidden;\n margin: 0 auto;\n padding: ", ";\n ", "\n"])), function (_ref3) {
31578
+ var containerWidth = _ref3.containerWidth;
31579
+ return containerWidth ? "\n max-width: " + (containerWidth + "px") + ";\n " : "\n max-width: 100%;\n width: 100%;\n ";
31535
31580
  }, function (_ref4) {
31536
- var height = _ref4.height,
31581
+ var containerHeight = _ref4.containerHeight,
31537
31582
  showOGMetadata = _ref4.showOGMetadata;
31538
- return height ? "\n max-height: " + (height + "px") + ";\n height: " + (showOGMetadata ? height + "px" : '0') + ";\n " : "\n max-height: 200px;\n height: " + (showOGMetadata ? '200px' : '0') + ";\n ";
31583
+ return containerHeight ? "\n max-height: " + (containerHeight + "px") + ";\n height: " + (showOGMetadata ? containerHeight + "px" : '0') + ";\n " : "\n height: 0;\n ";
31539
31584
  }, function (_ref5) {
31540
- var showOGMetadata = _ref5.showOGMetadata;
31541
- return showOGMetadata ? 1 : 0;
31585
+ var showOGMetadata = _ref5.showOGMetadata,
31586
+ containerHeight = _ref5.containerHeight;
31587
+ return showOGMetadata && containerHeight ? 1 : 0;
31542
31588
  }, function (_ref6) {
31543
- var showOGMetadata = _ref6.showOGMetadata;
31544
- return showOGMetadata ? '0.3rem' : '0';
31589
+ var showOGMetadata = _ref6.showOGMetadata,
31590
+ containerHeight = _ref6.containerHeight;
31591
+ return showOGMetadata && containerHeight ? '4px' : '0';
31592
+ }, function (_ref7) {
31593
+ var shouldAnimate = _ref7.shouldAnimate;
31594
+ return shouldAnimate && "\n transition: height 0.2s ease;\n ";
31595
+ });
31596
+ var OGText = styled__default.div(_templateObject3$p || (_templateObject3$p = _taggedTemplateLiteralLoose(["\n padding: 0.5rem;\n margin: 0;\n ", "\n"])), function (_ref8) {
31597
+ var shouldAnimate = _ref8.shouldAnimate;
31598
+ return shouldAnimate && "\n transition: all 0.2s ease;\n ";
31545
31599
  });
31546
- var OGText = styled__default.div(_templateObject3$p || (_templateObject3$p = _taggedTemplateLiteralLoose(["\n padding: 0.5rem;\n margin: 0;\n transition: all 0.2s ease;\n"])));
31547
- var Url = styled__default.p(_templateObject4$l || (_templateObject4$l = _taggedTemplateLiteralLoose(["\n font-weight: normal;\n font-size: 13px;\n padding: 0;\n margin: 0 0 12px 0;\n color: gray;\n ", "\n transition: all 0.2s ease;\n"])), function (_ref7) {
31548
- var maxWidth = _ref7.maxWidth;
31600
+ var Url = styled__default.p(_templateObject4$l || (_templateObject4$l = _taggedTemplateLiteralLoose(["\n font-weight: normal;\n font-size: 13px;\n padding: 0;\n margin: 0 0 12px 0;\n color: gray;\n ", "\n ", "\n"])), function (_ref9) {
31601
+ var maxWidth = _ref9.maxWidth;
31549
31602
  return maxWidth && "\n max-width: " + (maxWidth + "px") + ";\n ";
31603
+ }, function (_ref0) {
31604
+ var shouldAnimate = _ref0.shouldAnimate;
31605
+ return shouldAnimate && "\n transition: all 0.2s ease;\n ";
31550
31606
  });
31551
- var Title = styled__default.p(_templateObject5$h || (_templateObject5$h = _taggedTemplateLiteralLoose(["\n font-weight: bold;\n font-size: 13px;\n padding: 0;\n display: flex;\n align-items: center;\n ", "\n transition: all 0.2s ease;\n"])), function (_ref8) {
31552
- var maxWidth = _ref8.maxWidth;
31607
+ var Title = styled__default.p(_templateObject5$h || (_templateObject5$h = _taggedTemplateLiteralLoose(["\n font-weight: bold;\n font-size: 13px;\n padding: 0;\n display: flex;\n align-items: center;\n ", "\n ", "\n"])), function (_ref1) {
31608
+ var maxWidth = _ref1.maxWidth;
31553
31609
  return maxWidth && "\n max-width: " + (maxWidth + "px") + ";\n ";
31610
+ }, function (_ref10) {
31611
+ var shouldAnimate = _ref10.shouldAnimate;
31612
+ return shouldAnimate && "\n transition: all 0.2s ease;\n ";
31554
31613
  });
31555
- var Desc = styled__default.p(_templateObject6$f || (_templateObject6$f = _taggedTemplateLiteralLoose(["\n font-weight: normal;\n font-size: 13px;\n padding: 0;\n ", "\n transition: all 0.2s ease;\n"])), function (_ref9) {
31556
- var maxWidth = _ref9.maxWidth;
31614
+ var Desc = styled__default.p(_templateObject6$f || (_templateObject6$f = _taggedTemplateLiteralLoose(["\n font-weight: normal;\n font-size: 13px;\n padding: 0;\n overflow: hidden;\n display: -webkit-box;\n -webkit-line-clamp: 3;\n -webkit-box-orient: vertical;\n ", "\n ", "\n"])), function (_ref11) {
31615
+ var maxWidth = _ref11.maxWidth;
31557
31616
  return maxWidth && "\n max-width: " + (maxWidth + "px") + ";\n ";
31617
+ }, function (_ref12) {
31618
+ var shouldAnimate = _ref12.shouldAnimate;
31619
+ return shouldAnimate && "\n transition: all 0.2s ease;\n ";
31620
+ });
31621
+ var Img = styled__default.img(_templateObject7$d || (_templateObject7$d = _taggedTemplateLiteralLoose(["\n ", "\n ", "\n\n object-fit: cover;\n ", "\n"])), function (_ref13) {
31622
+ var imageWidth = _ref13.imageWidth;
31623
+ return imageWidth && "\n max-width: " + (imageWidth + "px") + ";\n width: " + ("calc(" + imageWidth + "px - 8px)") + ";\n ";
31624
+ }, function (_ref14) {
31625
+ var imageHeight = _ref14.imageHeight;
31626
+ return imageHeight && "\n max-height: " + (imageHeight + "px") + ";\n min-height: " + (imageHeight + "px") + ";\n height: " + (imageHeight + "px") + ";\n ";
31627
+ }, function (_ref15) {
31628
+ var shouldAnimate = _ref15.shouldAnimate;
31629
+ return shouldAnimate && "\n transition: height 0.2s ease;\n ";
31558
31630
  });
31559
- var Img = styled__default.img(_templateObject7$d || (_templateObject7$d = _taggedTemplateLiteralLoose(["\n ", "\n ", "\n object-fit: cover;\n transition: height 0.2s ease;\n"])), function (_ref0) {
31560
- var width = _ref0.width;
31561
- return width && "\n max-width: " + (width + "px") + ";\n min-width: " + (width + "px") + ";\n width: " + (width + "px") + ";\n ";
31562
- }, function (_ref1) {
31563
- var height = _ref1.height;
31564
- return height && "\n max-height: " + (height + "px") + ";\n min-height: " + (height + "px") + ";\n height: " + (height + "px") + ";\n ";
31631
+ var Favicon = styled__default.img(_templateObject8$c || (_templateObject8$c = _taggedTemplateLiteralLoose(["\n ", "\n width: 24px;\n height: 24px;\n object-fit: contain;\n margin-right: 4px;\n"])), function (_ref16) {
31632
+ var shouldAnimate = _ref16.shouldAnimate;
31633
+ return shouldAnimate && "\n transition: all 0.2s ease;\n ";
31565
31634
  });
31566
- var Favicon = styled__default.img(_templateObject8$c || (_templateObject8$c = _taggedTemplateLiteralLoose(["\n transition: all 0.2s ease;\n width: 24px;\n height: 24px;\n object-fit: contain;\n margin-right: 4px;\n"])));
31567
31635
 
31568
31636
  var _templateObject$B, _templateObject2$w, _templateObject3$q, _templateObject4$m, _templateObject5$i;
31569
31637
  var MessageBody = function MessageBody(_ref) {
@@ -36145,7 +36213,6 @@ var AudioRecord = function AudioRecord(_ref) {
36145
36213
  handleStopRecording();
36146
36214
  if (currentRecordedFile) {
36147
36215
  var _wavesurfer$current2;
36148
- removeAudioRecordingFromMap(currentChannelId);
36149
36216
  dispatch(setChannelDraftMessageIsRemovedAC(currentChannelId));
36150
36217
  setRecordedFile(null);
36151
36218
  setPlayAudio(false);
@@ -36154,8 +36221,9 @@ var AudioRecord = function AudioRecord(_ref) {
36154
36221
  }
36155
36222
  } else {
36156
36223
  shouldDraw = false;
36157
- recorder.stop();
36224
+ recorder === null || recorder === void 0 ? void 0 : recorder.stop();
36158
36225
  }
36226
+ removeAudioRecordingFromMap(currentChannelId);
36159
36227
  setRecordingIsReadyToPlay(false);
36160
36228
  setStartRecording(false);
36161
36229
  setCurrentTime(0);
package/index.modern.js CHANGED
@@ -10327,7 +10327,9 @@ var initialState$1 = {
10327
10327
  openedMessageMenu: '',
10328
10328
  attachmentsUploadingProgress: {},
10329
10329
  playingAudioId: null,
10330
- selectedMessagesMap: null
10330
+ selectedMessagesMap: null,
10331
+ oGMetadata: {},
10332
+ attachmentUpdatedMap: {}
10331
10333
  };
10332
10334
  var messageSlice = createSlice({
10333
10335
  name: 'messages',
@@ -10456,39 +10458,8 @@ var messageSlice = createSlice({
10456
10458
  updateMessageAttachment: function updateMessageAttachment(state, action) {
10457
10459
  var _action$payload4 = action.payload,
10458
10460
  url = _action$payload4.url,
10459
- messageId = _action$payload4.messageId,
10460
- params = _action$payload4.params;
10461
- state.activeChannelMessages = state.activeChannelMessages.map(function (message) {
10462
- if (message.id === messageId) {
10463
- for (var index = 0; index < message.attachments.length; index++) {
10464
- var attachment = message.attachments[index];
10465
- if (attachment.url === url) {
10466
- message.attachments[index] = _extends({}, attachment, params);
10467
- }
10468
- }
10469
- }
10470
- if (message.attachments.length) {
10471
- var detachedAttachments = message.attachments.map(function (att) {
10472
- var _att$user, _att$user2;
10473
- return _extends({}, att, {
10474
- user: _extends({}, att.user, {
10475
- metadata: _extends({}, ((_att$user = att.user) === null || _att$user === void 0 ? void 0 : _att$user.metadata) || {}),
10476
- presence: _extends({}, ((_att$user2 = att.user) === null || _att$user2 === void 0 ? void 0 : _att$user2.presence) || {})
10477
- })
10478
- });
10479
- });
10480
- updateMessageOnAllMessages(messageId, {
10481
- attachments: detachedAttachments
10482
- });
10483
- updateMessageOnMap(message.channelId, {
10484
- messageId: messageId,
10485
- params: {
10486
- attachments: detachedAttachments
10487
- }
10488
- });
10489
- }
10490
- return message;
10491
- });
10461
+ attachmentUrl = _action$payload4.attachmentUrl;
10462
+ state.attachmentUpdatedMap[url] = attachmentUrl;
10492
10463
  },
10493
10464
  addReactionToMessage: function addReactionToMessage(state, action) {
10494
10465
  var _action$payload5 = action.payload,
@@ -10670,6 +10641,21 @@ var messageSlice = createSlice({
10670
10641
  },
10671
10642
  clearSelectedMessages: function clearSelectedMessages(state) {
10672
10643
  state.selectedMessagesMap = null;
10644
+ },
10645
+ setOGMetadata: function setOGMetadata(state, action) {
10646
+ var _action$payload10 = action.payload,
10647
+ url = _action$payload10.url,
10648
+ metadata = _action$payload10.metadata;
10649
+ state.oGMetadata[url] = metadata;
10650
+ },
10651
+ updateOGMetadata: function updateOGMetadata(state, action) {
10652
+ var _action$payload11 = action.payload,
10653
+ url = _action$payload11.url,
10654
+ metadata = _action$payload11.metadata;
10655
+ if (metadata) {
10656
+ var existing = state.oGMetadata[url];
10657
+ state.oGMetadata[url] = existing ? _extends({}, existing, metadata) : metadata;
10658
+ }
10673
10659
  }
10674
10660
  },
10675
10661
  extraReducers: function extraReducers(builder) {
@@ -10719,7 +10705,9 @@ var _messageSlice$actions = messageSlice.actions,
10719
10705
  setPlayingAudioId = _messageSlice$actions.setPlayingAudioId,
10720
10706
  addSelectedMessage = _messageSlice$actions.addSelectedMessage,
10721
10707
  removeSelectedMessage = _messageSlice$actions.removeSelectedMessage,
10722
- clearSelectedMessages = _messageSlice$actions.clearSelectedMessages;
10708
+ clearSelectedMessages = _messageSlice$actions.clearSelectedMessages,
10709
+ setOGMetadata = _messageSlice$actions.setOGMetadata,
10710
+ updateOGMetadata = _messageSlice$actions.updateOGMetadata;
10723
10711
  var MessageReducer = messageSlice.reducer;
10724
10712
 
10725
10713
  var initialState$2 = {
@@ -11799,11 +11787,22 @@ function setMessagesHasNextAC(hasNext) {
11799
11787
  hasNext: hasNext
11800
11788
  });
11801
11789
  }
11802
- function setUpdateMessageAttachmentAC(url, messageId, params) {
11790
+ function setOGMetadataAC(url, metadata) {
11791
+ return setOGMetadata({
11792
+ url: url,
11793
+ metadata: metadata
11794
+ });
11795
+ }
11796
+ function updateOGMetadataAC(url, metadata) {
11797
+ return updateOGMetadata({
11798
+ url: url,
11799
+ metadata: metadata
11800
+ });
11801
+ }
11802
+ function setUpdateMessageAttachmentAC(url, attachmentUrl) {
11803
11803
  return updateMessageAttachment({
11804
11804
  url: url,
11805
- messageId: messageId,
11806
- params: params
11805
+ attachmentUrl: attachmentUrl
11807
11806
  });
11808
11807
  }
11809
11808
  function updateMessageAC(messageId, params, addIfNotExists) {
@@ -17114,6 +17113,9 @@ var playingAudioIdSelector = function playingAudioIdSelector(store) {
17114
17113
  var selectedMessagesMapSelector = function selectedMessagesMapSelector(store) {
17115
17114
  return store.MessageReducer.selectedMessagesMap;
17116
17115
  };
17116
+ var attachmentUpdatedMapSelector = function attachmentUpdatedMapSelector(store) {
17117
+ return store.MessageReducer.attachmentUpdatedMap;
17118
+ };
17117
17119
 
17118
17120
  var getFrame = function getFrame(videoSrc, time) {
17119
17121
  try {
@@ -29574,13 +29576,17 @@ var Attachment = function Attachment(_ref) {
29574
29576
  var connectionStatus = useSelector(connectionStatusSelector);
29575
29577
  var theme = useSelector(themeSelector);
29576
29578
  var imageContRef = useRef(null);
29577
- var _useState = useState(!attachment.attachmentUrl),
29579
+ var attachmentUpdatedMap = useSelector(attachmentUpdatedMapSelector) || {};
29580
+ var attachmentUrlFromMap = useMemo(function () {
29581
+ return attachmentUpdatedMap[attachment.url];
29582
+ }, [attachmentUpdatedMap, attachment.url]);
29583
+ var _useState = useState(!attachmentUrlFromMap),
29578
29584
  imageLoading = _useState[0],
29579
29585
  setImageLoading = _useState[1];
29580
29586
  var _useState2 = useState(false),
29581
29587
  downloadingFile = _useState2[0],
29582
29588
  setDownloadingFile = _useState2[1];
29583
- var _useState3 = useState(''),
29589
+ var _useState3 = useState(attachmentUrlFromMap),
29584
29590
  attachmentUrl = _useState3[0],
29585
29591
  setAttachmentUrl = _useState3[1];
29586
29592
  var _useState4 = useState(),
@@ -29604,27 +29610,26 @@ var Attachment = function Attachment(_ref) {
29604
29610
  var fileNameRef = useRef(null);
29605
29611
  var customDownloader = getCustomDownloader();
29606
29612
  var previewFileType = isPreview && attachment.data.type.split('/')[0];
29613
+ var attachmentMetadata = useMemo(function () {
29614
+ return isJSON(attachment.metadata) ? JSON.parse(attachment.metadata) : attachment.metadata;
29615
+ }, [attachment.metadata]);
29607
29616
  var _useMemo = useMemo(function () {
29608
29617
  var attachmentData = null;
29609
- if (attachment.metadata && typeof attachment.metadata === 'string') {
29610
- attachmentData = isJSON(attachment.metadata) ? JSON.parse(attachment.metadata) : attachment.metadata;
29611
- } else if (attachment.metadata && attachment.metadata.szw && attachment.metadata.szh) {
29612
- attachmentData = attachment.metadata;
29613
- }
29618
+ attachmentData = attachmentMetadata;
29614
29619
  return attachmentData && attachmentData.szw && attachmentData.szh ? calculateRenderedImageWidth(attachmentData.szw, attachmentData.szh, attachment.type === attachmentTypes.image ? imageAttachmentMaxWidth : videoAttachmentMaxWidth, attachment.type === attachmentTypes.image ? imageAttachmentMaxHeight || 400 : videoAttachmentMaxHeight) : [];
29615
- }, []),
29620
+ }, [attachmentMetadata]),
29616
29621
  renderWidth = _useMemo[0],
29617
29622
  renderHeight = _useMemo[1];
29618
29623
  var isInUploadingState = attachmentCompilationState[attachment.tid] && (attachmentCompilationState[attachment.tid] === UPLOAD_STATE.UPLOADING || attachmentCompilationState[attachment.tid] === UPLOAD_STATE.PAUSED);
29619
29624
  var attachmentThumb;
29620
29625
  var withPrefix = true;
29621
- if (attachment.type !== attachmentTypes.voice && attachment.type !== attachmentTypes.link && attachment.metadata && attachment.metadata.tmb) {
29626
+ if (attachment.type !== attachmentTypes.voice && attachment.type !== attachmentTypes.link && attachmentMetadata && attachmentMetadata.tmb) {
29622
29627
  try {
29623
- if (attachment.metadata.tmb.length < 70) {
29624
- attachmentThumb = base64ToToDataURL(attachment.metadata.tmb);
29628
+ if (attachmentMetadata.tmb.length < 70) {
29629
+ attachmentThumb = base64ToToDataURL(attachmentMetadata.tmb);
29625
29630
  withPrefix = false;
29626
29631
  } else {
29627
- attachmentThumb = attachment.metadata && attachment.metadata.tmb;
29632
+ attachmentThumb = attachmentMetadata && attachmentMetadata.tmb;
29628
29633
  }
29629
29634
  } catch (e) {
29630
29635
  log.error('error on get attachmentThumb', e);
@@ -29788,9 +29793,7 @@ var Attachment = function Attachment(_ref) {
29788
29793
  if (attachment.type === attachmentTypes.image && !isPreview) {
29789
29794
  if (cachedUrl) {
29790
29795
  setAttachmentUrl(cachedUrl);
29791
- dispatch(setUpdateMessageAttachmentAC(attachment.url, attachment.messageId, {
29792
- attachmentUrl: cachedUrl
29793
- }));
29796
+ dispatch(setUpdateMessageAttachmentAC(attachment.url, cachedUrl));
29794
29797
  setIsCached(true);
29795
29798
  } else {
29796
29799
  setIsCached(false);
@@ -31363,54 +31366,95 @@ var validateUrl = function validateUrl(url) {
31363
31366
  }
31364
31367
  };
31365
31368
  var OGMetadata = function OGMetadata(_ref) {
31366
- var _metadata$og6, _metadata$og6$image, _metadata$og6$image$, _metadata$og7, _metadata$og7$image, _metadata$og7$image$, _metadata$og8, _metadata$og8$image, _metadata$og8$image$, _metadata$og9, _metadata$og0, _metadata$og0$favicon, _metadata$og1, _metadata$og1$favicon, _metadata$og10, _metadata$og11, _metadata$og12;
31369
+ var _metadata$og4, _metadata$og4$image, _metadata$og4$image$, _metadata$og5, _metadata$og5$image, _metadata$og5$image$, _metadata$og6, _metadata$og7, _metadata$og7$favicon, _metadata$og8, _metadata$og8$favicon, _metadata$og9, _metadata$og0, _metadata$og1;
31367
31370
  var attachments = _ref.attachments,
31368
31371
  state = _ref.state;
31369
- var _useState = useState(null),
31370
- metadata = _useState[0],
31371
- setMetadata = _useState[1];
31372
- var _useState2 = useState(true),
31373
- imageLoadError = _useState2[0],
31374
- setImageLoadError = _useState2[1];
31375
- var _useState3 = useState(true),
31376
- faviconLoadError = _useState3[0],
31377
- setFaviconLoadError = _useState3[1];
31378
- var _useState4 = useState(false),
31379
- imageLoaded = _useState4[0],
31380
- setImageLoaded = _useState4[1];
31381
- var _useState5 = useState(0),
31382
- imageWidth = _useState5[0],
31383
- setImageWidth = _useState5[1];
31384
- var _useState6 = useState(0),
31385
- imageHeight = _useState6[0],
31386
- setImageHeight = _useState6[1];
31372
+ var dispatch = useDispatch();
31373
+ var oGMetadata = useSelector(function (state) {
31374
+ return state.MessageReducer.oGMetadata;
31375
+ });
31387
31376
  var attachment = useMemo(function () {
31388
31377
  return attachments.find(function (attachment) {
31389
31378
  return attachment.type === attachmentTypes.link;
31390
31379
  });
31391
31380
  }, [attachments]);
31381
+ var metadata = useMemo(function () {
31382
+ return oGMetadata[attachment === null || attachment === void 0 ? void 0 : attachment.url] || null;
31383
+ }, [oGMetadata, attachment === null || attachment === void 0 ? void 0 : attachment.url]);
31384
+ var _useState = useState(false),
31385
+ imageLoadError = _useState[0],
31386
+ setImageLoadError = _useState[1];
31387
+ var _useState2 = useState(false),
31388
+ faviconLoadError = _useState2[0],
31389
+ setFaviconLoadError = _useState2[1];
31390
+ var _useState3 = useState(false),
31391
+ shouldAnimate = _useState3[0],
31392
+ setShouldAnimate = _useState3[1];
31393
+ var handleMetadata = useCallback(function (metadata) {
31394
+ if (metadata) {
31395
+ dispatch(setOGMetadataAC(attachment === null || attachment === void 0 ? void 0 : attachment.url, metadata));
31396
+ } else {
31397
+ dispatch(setOGMetadataAC(attachment === null || attachment === void 0 ? void 0 : attachment.url, null));
31398
+ }
31399
+ }, []);
31392
31400
  var ogMetadataQueryBuilder = useCallback(function (url) {
31393
31401
  try {
31394
31402
  var client = getClient();
31395
- var _temp2 = function () {
31403
+ var _temp3 = function () {
31396
31404
  if (client) {
31397
- var _temp = _catch(function () {
31405
+ var _temp2 = _catch(function () {
31398
31406
  var queryBuilder = new client.MessageLinkOGQueryBuilder(url);
31399
31407
  return Promise.resolve(queryBuilder.build()).then(function (query) {
31400
31408
  return Promise.resolve(query.loadOGData()).then(function (metadata) {
31401
- return Promise.resolve(storeMetadata(url, metadata)).then(function () {
31402
- setMetadata(metadata);
31403
- });
31409
+ var _metadata$og, _metadata$og$image, _metadata$og$image$;
31410
+ var image = new Image();
31411
+ image.src = metadata === null || metadata === void 0 ? void 0 : (_metadata$og = metadata.og) === null || _metadata$og === void 0 ? void 0 : (_metadata$og$image = _metadata$og.image) === null || _metadata$og$image === void 0 ? void 0 : (_metadata$og$image$ = _metadata$og$image[0]) === null || _metadata$og$image$ === void 0 ? void 0 : _metadata$og$image$.url;
31412
+ var _temp = function () {
31413
+ if (image.src) {
31414
+ image.onload = function () {
31415
+ try {
31416
+ var imageWidth = image.width;
31417
+ var imageHeight = image.height;
31418
+ return Promise.resolve(storeMetadata(url, _extends({}, metadata, {
31419
+ imageWidth: imageWidth,
31420
+ imageHeight: imageHeight
31421
+ }))).then(function () {
31422
+ handleMetadata(_extends({}, metadata, {
31423
+ imageWidth: imageWidth,
31424
+ imageHeight: imageHeight
31425
+ }));
31426
+ });
31427
+ } catch (e) {
31428
+ return Promise.reject(e);
31429
+ }
31430
+ };
31431
+ image.onerror = function () {
31432
+ try {
31433
+ setImageLoadError(true);
31434
+ return Promise.resolve(storeMetadata(url, _extends({}, metadata))).then(function () {
31435
+ handleMetadata(_extends({}, metadata));
31436
+ });
31437
+ } catch (e) {
31438
+ return Promise.reject(e);
31439
+ }
31440
+ };
31441
+ } else {
31442
+ return Promise.resolve(storeMetadata(url, _extends({}, metadata))).then(function () {
31443
+ handleMetadata(_extends({}, metadata));
31444
+ });
31445
+ }
31446
+ }();
31447
+ if (_temp && _temp.then) return _temp.then(function () {});
31404
31448
  });
31405
31449
  });
31406
31450
  }, function () {
31407
31451
  console.log('Failed to fetch OG metadata');
31408
- setMetadata(null);
31452
+ handleMetadata(null);
31409
31453
  });
31410
- if (_temp && _temp.then) return _temp.then(function () {});
31454
+ if (_temp2 && _temp2.then) return _temp2.then(function () {});
31411
31455
  }
31412
31456
  }();
31413
- return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {
31457
+ return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {
31414
31458
  return null;
31415
31459
  }) : null);
31416
31460
  } catch (e) {
@@ -31418,16 +31462,16 @@ var OGMetadata = function OGMetadata(_ref) {
31418
31462
  }
31419
31463
  }, []);
31420
31464
  useEffect(function () {
31421
- if (attachment !== null && attachment !== void 0 && attachment.id && attachment !== null && attachment !== void 0 && attachment.url) {
31465
+ if (attachment !== null && attachment !== void 0 && attachment.id && attachment !== null && attachment !== void 0 && attachment.url && !metadata) {
31466
+ setShouldAnimate(true);
31422
31467
  var url = attachment === null || attachment === void 0 ? void 0 : attachment.url;
31423
31468
  if (url) {
31424
31469
  getMetadata(url).then(function (cachedMetadata) {
31425
31470
  try {
31426
31471
  if (cachedMetadata) {
31427
- setMetadata(cachedMetadata);
31428
- } else {
31429
- ogMetadataQueryBuilder(url);
31472
+ handleMetadata(cachedMetadata);
31430
31473
  }
31474
+ ogMetadataQueryBuilder(url);
31431
31475
  return Promise.resolve();
31432
31476
  } catch (e) {
31433
31477
  return Promise.reject(e);
@@ -31437,7 +31481,7 @@ var OGMetadata = function OGMetadata(_ref) {
31437
31481
  });
31438
31482
  }
31439
31483
  }
31440
- }, [attachment === null || attachment === void 0 ? void 0 : attachment.url]);
31484
+ }, [attachment === null || attachment === void 0 ? void 0 : attachment.url, metadata]);
31441
31485
  var ogUrl = useMemo(function () {
31442
31486
  var url = attachment === null || attachment === void 0 ? void 0 : attachment.url;
31443
31487
  var urlObj = validateUrl(url);
@@ -31447,102 +31491,126 @@ var OGMetadata = function OGMetadata(_ref) {
31447
31491
  return url;
31448
31492
  }, [attachment === null || attachment === void 0 ? void 0 : attachment.url]);
31449
31493
  var showOGMetadata = useMemo(function () {
31450
- var _metadata$og, _metadata$og2, _metadata$og2$image, _metadata$og2$image$, _metadata$og3;
31451
- return state !== 'deleted' && (metadata === null || metadata === void 0 ? void 0 : (_metadata$og = metadata.og) === null || _metadata$og === void 0 ? void 0 : _metadata$og.title) && (metadata === null || metadata === void 0 ? void 0 : (_metadata$og2 = metadata.og) === null || _metadata$og2 === void 0 ? void 0 : (_metadata$og2$image = _metadata$og2.image) === null || _metadata$og2$image === void 0 ? void 0 : (_metadata$og2$image$ = _metadata$og2$image[0]) === null || _metadata$og2$image$ === void 0 ? void 0 : _metadata$og2$image$.url) && (metadata === null || metadata === void 0 ? void 0 : (_metadata$og3 = metadata.og) === null || _metadata$og3 === void 0 ? void 0 : _metadata$og3.description) && metadata;
31494
+ var _metadata$og2, _metadata$og3;
31495
+ return state !== 'deleted' && (metadata === null || metadata === void 0 ? void 0 : (_metadata$og2 = metadata.og) === null || _metadata$og2 === void 0 ? void 0 : _metadata$og2.title) && (metadata === null || metadata === void 0 ? void 0 : (_metadata$og3 = metadata.og) === null || _metadata$og3 === void 0 ? void 0 : _metadata$og3.description) && metadata;
31452
31496
  }, [state, metadata]);
31453
- useEffect(function () {
31454
- var _metadata$og4, _metadata$og4$image, _metadata$og4$image$;
31455
- if (metadata !== null && metadata !== void 0 && (_metadata$og4 = metadata.og) !== null && _metadata$og4 !== void 0 && (_metadata$og4$image = _metadata$og4.image) !== null && _metadata$og4$image !== void 0 && (_metadata$og4$image$ = _metadata$og4$image[0]) !== null && _metadata$og4$image$ !== void 0 && _metadata$og4$image$.url) {
31456
- var _metadata$og5, _metadata$og5$image, _metadata$og5$image$;
31457
- var image = new Image();
31458
- image.src = metadata === null || metadata === void 0 ? void 0 : (_metadata$og5 = metadata.og) === null || _metadata$og5 === void 0 ? void 0 : (_metadata$og5$image = _metadata$og5.image) === null || _metadata$og5$image === void 0 ? void 0 : (_metadata$og5$image$ = _metadata$og5$image[0]) === null || _metadata$og5$image$ === void 0 ? void 0 : _metadata$og5$image$.url;
31459
- image.onload = function () {
31460
- var imageWidth = image.width;
31461
- var imageHeight = image.height;
31462
- setImageWidth(imageWidth);
31463
- setImageHeight(imageHeight);
31464
- setImageLoadError(false);
31465
- setImageLoaded(true);
31466
- };
31467
- image.onerror = function () {
31468
- setImageLoadError(true);
31469
- setImageLoaded(true);
31470
- };
31471
- }
31472
- }, [metadata === null || metadata === void 0 ? void 0 : (_metadata$og6 = metadata.og) === null || _metadata$og6 === void 0 ? void 0 : (_metadata$og6$image = _metadata$og6.image) === null || _metadata$og6$image === void 0 ? void 0 : (_metadata$og6$image$ = _metadata$og6$image[0]) === null || _metadata$og6$image$ === void 0 ? void 0 : _metadata$og6$image$.url]);
31473
31497
  var calculatedImageHeight = useMemo(function () {
31474
- return imageHeight / (imageWidth / 400);
31475
- }, [imageWidth, imageHeight]);
31498
+ if (!(metadata !== null && metadata !== void 0 && metadata.imageWidth)) {
31499
+ return 0;
31500
+ }
31501
+ return (metadata === null || metadata === void 0 ? void 0 : metadata.imageHeight) / ((metadata === null || metadata === void 0 ? void 0 : metadata.imageWidth) / 400);
31502
+ }, [metadata === null || metadata === void 0 ? void 0 : metadata.imageWidth, metadata === null || metadata === void 0 ? void 0 : metadata.imageHeight]);
31476
31503
  return /*#__PURE__*/React__default.createElement(OGMetadataContainer, {
31477
31504
  showOGMetadata: !!showOGMetadata
31478
31505
  }, /*#__PURE__*/React__default.createElement("div", {
31479
31506
  onClick: function onClick() {
31480
31507
  window.open(attachment === null || attachment === void 0 ? void 0 : attachment.url, '_blank');
31508
+ },
31509
+ style: {
31510
+ width: showOGMetadata ? '400px' : 'auto'
31481
31511
  }
31482
31512
  }, /*#__PURE__*/React__default.createElement(ImageContainer, {
31483
- showOGMetadata: !!showOGMetadata && !imageLoadError && imageLoaded,
31484
- width: 400,
31485
- height: calculatedImageHeight
31486
- }, metadata !== null && metadata !== void 0 && (_metadata$og7 = metadata.og) !== null && _metadata$og7 !== void 0 && (_metadata$og7$image = _metadata$og7.image) !== null && _metadata$og7$image !== void 0 && (_metadata$og7$image$ = _metadata$og7$image[0]) !== null && _metadata$og7$image$ !== void 0 && _metadata$og7$image$.url && !imageLoadError ? (/*#__PURE__*/React__default.createElement(Img, {
31487
- src: metadata === null || metadata === void 0 ? void 0 : (_metadata$og8 = metadata.og) === null || _metadata$og8 === void 0 ? void 0 : (_metadata$og8$image = _metadata$og8.image) === null || _metadata$og8$image === void 0 ? void 0 : (_metadata$og8$image$ = _metadata$og8$image[0]) === null || _metadata$og8$image$ === void 0 ? void 0 : _metadata$og8$image$.url,
31513
+ showOGMetadata: !!showOGMetadata && !imageLoadError,
31514
+ containerWidth: 400,
31515
+ containerHeight: calculatedImageHeight,
31516
+ shouldAnimate: shouldAnimate
31517
+ }, metadata !== null && metadata !== void 0 && (_metadata$og4 = metadata.og) !== null && _metadata$og4 !== void 0 && (_metadata$og4$image = _metadata$og4.image) !== null && _metadata$og4$image !== void 0 && (_metadata$og4$image$ = _metadata$og4$image[0]) !== null && _metadata$og4$image$ !== void 0 && _metadata$og4$image$.url && !imageLoadError ? (/*#__PURE__*/React__default.createElement(Img, {
31518
+ src: metadata === null || metadata === void 0 ? void 0 : (_metadata$og5 = metadata.og) === null || _metadata$og5 === void 0 ? void 0 : (_metadata$og5$image = _metadata$og5.image) === null || _metadata$og5$image === void 0 ? void 0 : (_metadata$og5$image$ = _metadata$og5$image[0]) === null || _metadata$og5$image$ === void 0 ? void 0 : _metadata$og5$image$.url,
31488
31519
  alt: 'OG metadata image',
31489
- width: 400,
31490
- height: calculatedImageHeight
31491
- })) : null), showOGMetadata && imageLoaded ? (/*#__PURE__*/React__default.createElement(OGText, null, /*#__PURE__*/React__default.createElement(Url, {
31492
- maxWidth: 400
31493
- }, ogUrl), metadata !== null && metadata !== void 0 && (_metadata$og9 = metadata.og) !== null && _metadata$og9 !== void 0 && _metadata$og9.title ? (/*#__PURE__*/React__default.createElement(Title, {
31494
- maxWidth: 400
31495
- }, metadata !== null && metadata !== void 0 && (_metadata$og0 = metadata.og) !== null && _metadata$og0 !== void 0 && (_metadata$og0$favicon = _metadata$og0.favicon) !== null && _metadata$og0$favicon !== void 0 && _metadata$og0$favicon.url && !faviconLoadError ? (/*#__PURE__*/React__default.createElement(Favicon, {
31496
- src: metadata === null || metadata === void 0 ? void 0 : (_metadata$og1 = metadata.og) === null || _metadata$og1 === void 0 ? void 0 : (_metadata$og1$favicon = _metadata$og1.favicon) === null || _metadata$og1$favicon === void 0 ? void 0 : _metadata$og1$favicon.url,
31520
+ imageWidth: 400,
31521
+ imageHeight: calculatedImageHeight,
31522
+ shouldAnimate: shouldAnimate
31523
+ })) : null), showOGMetadata ? (/*#__PURE__*/React__default.createElement(OGText, {
31524
+ shouldAnimate: shouldAnimate
31525
+ }, /*#__PURE__*/React__default.createElement(Url, {
31526
+ maxWidth: 400,
31527
+ shouldAnimate: shouldAnimate
31528
+ }, ogUrl), metadata !== null && metadata !== void 0 && (_metadata$og6 = metadata.og) !== null && _metadata$og6 !== void 0 && _metadata$og6.title ? (/*#__PURE__*/React__default.createElement(Title, {
31529
+ maxWidth: 400,
31530
+ shouldAnimate: shouldAnimate
31531
+ }, metadata !== null && metadata !== void 0 && (_metadata$og7 = metadata.og) !== null && _metadata$og7 !== void 0 && (_metadata$og7$favicon = _metadata$og7.favicon) !== null && _metadata$og7$favicon !== void 0 && _metadata$og7$favicon.url && !faviconLoadError ? (/*#__PURE__*/React__default.createElement(Favicon, {
31532
+ shouldAnimate: shouldAnimate,
31533
+ src: metadata === null || metadata === void 0 ? void 0 : (_metadata$og8 = metadata.og) === null || _metadata$og8 === void 0 ? void 0 : (_metadata$og8$favicon = _metadata$og8.favicon) === null || _metadata$og8$favicon === void 0 ? void 0 : _metadata$og8$favicon.url,
31497
31534
  onLoad: function onLoad() {
31498
31535
  return setFaviconLoadError(false);
31499
31536
  },
31500
31537
  onError: function onError() {
31501
- return setFaviconLoadError(true);
31538
+ dispatch(updateOGMetadataAC(attachment === null || attachment === void 0 ? void 0 : attachment.url, _extends({}, metadata, {
31539
+ og: _extends({}, metadata === null || metadata === void 0 ? void 0 : metadata.og, {
31540
+ favicon: {
31541
+ url: ''
31542
+ }
31543
+ })
31544
+ })));
31545
+ setFaviconLoadError(true);
31502
31546
  }
31503
- })) : null, /*#__PURE__*/React__default.createElement("span", null, metadata === null || metadata === void 0 ? void 0 : (_metadata$og10 = metadata.og) === null || _metadata$og10 === void 0 ? void 0 : _metadata$og10.title))) : null, metadata !== null && metadata !== void 0 && (_metadata$og11 = metadata.og) !== null && _metadata$og11 !== void 0 && _metadata$og11.description ? /*#__PURE__*/React__default.createElement(Desc, {
31504
- maxWidth: 400
31505
- }, metadata === null || metadata === void 0 ? void 0 : (_metadata$og12 = metadata.og) === null || _metadata$og12 === void 0 ? void 0 : _metadata$og12.description) : null)) : null));
31547
+ })) : null, /*#__PURE__*/React__default.createElement("span", null, metadata === null || metadata === void 0 ? void 0 : (_metadata$og9 = metadata.og) === null || _metadata$og9 === void 0 ? void 0 : _metadata$og9.title))) : null, metadata !== null && metadata !== void 0 && (_metadata$og0 = metadata.og) !== null && _metadata$og0 !== void 0 && _metadata$og0.description ? (/*#__PURE__*/React__default.createElement(Desc, {
31548
+ maxWidth: 400,
31549
+ shouldAnimate: shouldAnimate
31550
+ }, metadata === null || metadata === void 0 ? void 0 : (_metadata$og1 = metadata.og) === null || _metadata$og1 === void 0 ? void 0 : _metadata$og1.description)) : null)) : null));
31506
31551
  };
31507
31552
  var OGMetadataContainer = styled.div(_templateObject$A || (_templateObject$A = _taggedTemplateLiteralLoose(["\n min-width: inherit;\n max-width: inherit;\n display: grid;\n grid-template-columns: 1fr;\n background-color: rgba(0, 0, 0, 0.034);\n border-radius: 6px;\n margin-bottom: 0.4rem;\n margin: 0 auto;\n margin-bottom: ", ";\n &:hover {\n background-color: rgba(0, 0, 0, 0.1);\n cursor: pointer;\n }\n"])), function (_ref2) {
31508
31553
  var showOGMetadata = _ref2.showOGMetadata;
31509
31554
  return showOGMetadata ? '0.8rem' : '0';
31510
31555
  });
31511
- var ImageContainer = styled.div(_templateObject2$v || (_templateObject2$v = _taggedTemplateLiteralLoose(["\n ", "\n\n ", "\n\n opacity: ", ";\n overflow: hidden;\n margin: 0 auto;\n padding: ", ";\n transition: height 0.2s ease;\n"])), function (_ref3) {
31512
- var width = _ref3.width;
31513
- return width ? "\n max-width: " + (width + "px") + ";\n " : "\n max-width: 100%;\n width: 100%;\n ";
31556
+ var ImageContainer = styled.div(_templateObject2$v || (_templateObject2$v = _taggedTemplateLiteralLoose(["\n ", "\n\n ", "\n\n opacity: ", ";\n overflow: hidden;\n margin: 0 auto;\n padding: ", ";\n ", "\n"])), function (_ref3) {
31557
+ var containerWidth = _ref3.containerWidth;
31558
+ return containerWidth ? "\n max-width: " + (containerWidth + "px") + ";\n " : "\n max-width: 100%;\n width: 100%;\n ";
31514
31559
  }, function (_ref4) {
31515
- var height = _ref4.height,
31560
+ var containerHeight = _ref4.containerHeight,
31516
31561
  showOGMetadata = _ref4.showOGMetadata;
31517
- return height ? "\n max-height: " + (height + "px") + ";\n height: " + (showOGMetadata ? height + "px" : '0') + ";\n " : "\n max-height: 200px;\n height: " + (showOGMetadata ? '200px' : '0') + ";\n ";
31562
+ return containerHeight ? "\n max-height: " + (containerHeight + "px") + ";\n height: " + (showOGMetadata ? containerHeight + "px" : '0') + ";\n " : "\n height: 0;\n ";
31518
31563
  }, function (_ref5) {
31519
- var showOGMetadata = _ref5.showOGMetadata;
31520
- return showOGMetadata ? 1 : 0;
31564
+ var showOGMetadata = _ref5.showOGMetadata,
31565
+ containerHeight = _ref5.containerHeight;
31566
+ return showOGMetadata && containerHeight ? 1 : 0;
31521
31567
  }, function (_ref6) {
31522
- var showOGMetadata = _ref6.showOGMetadata;
31523
- return showOGMetadata ? '0.3rem' : '0';
31568
+ var showOGMetadata = _ref6.showOGMetadata,
31569
+ containerHeight = _ref6.containerHeight;
31570
+ return showOGMetadata && containerHeight ? '4px' : '0';
31571
+ }, function (_ref7) {
31572
+ var shouldAnimate = _ref7.shouldAnimate;
31573
+ return shouldAnimate && "\n transition: height 0.2s ease;\n ";
31574
+ });
31575
+ var OGText = styled.div(_templateObject3$p || (_templateObject3$p = _taggedTemplateLiteralLoose(["\n padding: 0.5rem;\n margin: 0;\n ", "\n"])), function (_ref8) {
31576
+ var shouldAnimate = _ref8.shouldAnimate;
31577
+ return shouldAnimate && "\n transition: all 0.2s ease;\n ";
31524
31578
  });
31525
- var OGText = styled.div(_templateObject3$p || (_templateObject3$p = _taggedTemplateLiteralLoose(["\n padding: 0.5rem;\n margin: 0;\n transition: all 0.2s ease;\n"])));
31526
- var Url = styled.p(_templateObject4$l || (_templateObject4$l = _taggedTemplateLiteralLoose(["\n font-weight: normal;\n font-size: 13px;\n padding: 0;\n margin: 0 0 12px 0;\n color: gray;\n ", "\n transition: all 0.2s ease;\n"])), function (_ref7) {
31527
- var maxWidth = _ref7.maxWidth;
31579
+ var Url = styled.p(_templateObject4$l || (_templateObject4$l = _taggedTemplateLiteralLoose(["\n font-weight: normal;\n font-size: 13px;\n padding: 0;\n margin: 0 0 12px 0;\n color: gray;\n ", "\n ", "\n"])), function (_ref9) {
31580
+ var maxWidth = _ref9.maxWidth;
31528
31581
  return maxWidth && "\n max-width: " + (maxWidth + "px") + ";\n ";
31582
+ }, function (_ref0) {
31583
+ var shouldAnimate = _ref0.shouldAnimate;
31584
+ return shouldAnimate && "\n transition: all 0.2s ease;\n ";
31529
31585
  });
31530
- var Title = styled.p(_templateObject5$h || (_templateObject5$h = _taggedTemplateLiteralLoose(["\n font-weight: bold;\n font-size: 13px;\n padding: 0;\n display: flex;\n align-items: center;\n ", "\n transition: all 0.2s ease;\n"])), function (_ref8) {
31531
- var maxWidth = _ref8.maxWidth;
31586
+ var Title = styled.p(_templateObject5$h || (_templateObject5$h = _taggedTemplateLiteralLoose(["\n font-weight: bold;\n font-size: 13px;\n padding: 0;\n display: flex;\n align-items: center;\n ", "\n ", "\n"])), function (_ref1) {
31587
+ var maxWidth = _ref1.maxWidth;
31532
31588
  return maxWidth && "\n max-width: " + (maxWidth + "px") + ";\n ";
31589
+ }, function (_ref10) {
31590
+ var shouldAnimate = _ref10.shouldAnimate;
31591
+ return shouldAnimate && "\n transition: all 0.2s ease;\n ";
31533
31592
  });
31534
- var Desc = styled.p(_templateObject6$f || (_templateObject6$f = _taggedTemplateLiteralLoose(["\n font-weight: normal;\n font-size: 13px;\n padding: 0;\n ", "\n transition: all 0.2s ease;\n"])), function (_ref9) {
31535
- var maxWidth = _ref9.maxWidth;
31593
+ var Desc = styled.p(_templateObject6$f || (_templateObject6$f = _taggedTemplateLiteralLoose(["\n font-weight: normal;\n font-size: 13px;\n padding: 0;\n overflow: hidden;\n display: -webkit-box;\n -webkit-line-clamp: 3;\n -webkit-box-orient: vertical;\n ", "\n ", "\n"])), function (_ref11) {
31594
+ var maxWidth = _ref11.maxWidth;
31536
31595
  return maxWidth && "\n max-width: " + (maxWidth + "px") + ";\n ";
31596
+ }, function (_ref12) {
31597
+ var shouldAnimate = _ref12.shouldAnimate;
31598
+ return shouldAnimate && "\n transition: all 0.2s ease;\n ";
31599
+ });
31600
+ var Img = styled.img(_templateObject7$d || (_templateObject7$d = _taggedTemplateLiteralLoose(["\n ", "\n ", "\n\n object-fit: cover;\n ", "\n"])), function (_ref13) {
31601
+ var imageWidth = _ref13.imageWidth;
31602
+ return imageWidth && "\n max-width: " + (imageWidth + "px") + ";\n width: " + ("calc(" + imageWidth + "px - 8px)") + ";\n ";
31603
+ }, function (_ref14) {
31604
+ var imageHeight = _ref14.imageHeight;
31605
+ return imageHeight && "\n max-height: " + (imageHeight + "px") + ";\n min-height: " + (imageHeight + "px") + ";\n height: " + (imageHeight + "px") + ";\n ";
31606
+ }, function (_ref15) {
31607
+ var shouldAnimate = _ref15.shouldAnimate;
31608
+ return shouldAnimate && "\n transition: height 0.2s ease;\n ";
31537
31609
  });
31538
- var Img = styled.img(_templateObject7$d || (_templateObject7$d = _taggedTemplateLiteralLoose(["\n ", "\n ", "\n object-fit: cover;\n transition: height 0.2s ease;\n"])), function (_ref0) {
31539
- var width = _ref0.width;
31540
- return width && "\n max-width: " + (width + "px") + ";\n min-width: " + (width + "px") + ";\n width: " + (width + "px") + ";\n ";
31541
- }, function (_ref1) {
31542
- var height = _ref1.height;
31543
- return height && "\n max-height: " + (height + "px") + ";\n min-height: " + (height + "px") + ";\n height: " + (height + "px") + ";\n ";
31610
+ var Favicon = styled.img(_templateObject8$c || (_templateObject8$c = _taggedTemplateLiteralLoose(["\n ", "\n width: 24px;\n height: 24px;\n object-fit: contain;\n margin-right: 4px;\n"])), function (_ref16) {
31611
+ var shouldAnimate = _ref16.shouldAnimate;
31612
+ return shouldAnimate && "\n transition: all 0.2s ease;\n ";
31544
31613
  });
31545
- var Favicon = styled.img(_templateObject8$c || (_templateObject8$c = _taggedTemplateLiteralLoose(["\n transition: all 0.2s ease;\n width: 24px;\n height: 24px;\n object-fit: contain;\n margin-right: 4px;\n"])));
31546
31614
 
31547
31615
  var _templateObject$B, _templateObject2$w, _templateObject3$q, _templateObject4$m, _templateObject5$i;
31548
31616
  var MessageBody = function MessageBody(_ref) {
@@ -36124,7 +36192,6 @@ var AudioRecord = function AudioRecord(_ref) {
36124
36192
  handleStopRecording();
36125
36193
  if (currentRecordedFile) {
36126
36194
  var _wavesurfer$current2;
36127
- removeAudioRecordingFromMap(currentChannelId);
36128
36195
  dispatch(setChannelDraftMessageIsRemovedAC(currentChannelId));
36129
36196
  setRecordedFile(null);
36130
36197
  setPlayAudio(false);
@@ -36133,8 +36200,9 @@ var AudioRecord = function AudioRecord(_ref) {
36133
36200
  }
36134
36201
  } else {
36135
36202
  shouldDraw = false;
36136
- recorder.stop();
36203
+ recorder === null || recorder === void 0 ? void 0 : recorder.stop();
36137
36204
  }
36205
+ removeAudioRecordingFromMap(currentChannelId);
36138
36206
  setRecordingIsReadyToPlay(false);
36139
36207
  setStartRecording(false);
36140
36208
  setCurrentTime(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sceyt-chat-react-uikit",
3
- "version": "1.7.2-beta.1",
3
+ "version": "1.7.2-beta.3",
4
4
  "description": "Interactive React UI Components for Sceyt Chat.",
5
5
  "author": "Sceyt",
6
6
  "license": "MIT",
package/types/index.d.ts CHANGED
@@ -237,6 +237,8 @@ export interface IOGMetadata {
237
237
  url: string;
238
238
  }[];
239
239
  };
240
+ imageWidth?: number;
241
+ imageHeight?: number;
240
242
  }
241
243
  export declare type MuteTime = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 24;
242
244
  export declare type ICustomAvatarColors = [string, string, string, string, string, string];