sceyt-chat-react-uikit 1.7.5-beta.11 → 1.7.5-beta.13

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
@@ -13652,6 +13652,12 @@ var CopiedTooltip = styled__default.span(_templateObject41 || (_templateObject41
13652
13652
  return p.color;
13653
13653
  });
13654
13654
 
13655
+ var SceytReduxContext = /*#__PURE__*/React__default.createContext(null);
13656
+
13657
+ var useSelector = reactRedux.createSelectorHook(SceytReduxContext);
13658
+ var useDispatch = reactRedux.createDispatchHook(SceytReduxContext);
13659
+ var useStore = reactRedux.createStoreHook(SceytReduxContext);
13660
+
13655
13661
  var _templateObject$1, _templateObject2$1, _templateObject3$1, _templateObject4$1, _templateObject5$1;
13656
13662
  var StatusText = styled__default.span(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteralLoose(["\n color: ", ";\n font-weight: 400;\n font-size: ", ";\n"])), function (props) {
13657
13663
  return props.color;
@@ -13727,7 +13733,7 @@ var MessageStatusIcon = function MessageStatusIcon(_ref) {
13727
13733
  });
13728
13734
  }
13729
13735
  };
13730
- var linkifyTextPart = function linkifyTextPart(textPart, match, target) {
13736
+ var linkifyTextPart = function linkifyTextPart(textPart, match, target, isInviteLink, onInviteLinkClick) {
13731
13737
  if (target === void 0) {
13732
13738
  target = '_blank';
13733
13739
  }
@@ -13738,18 +13744,29 @@ var linkifyTextPart = function linkifyTextPart(textPart, match, target) {
13738
13744
  var matchIndex = textPart.indexOf(matchItem.text, lastFoundIndex);
13739
13745
  lastFoundIndex = matchIndex + matchItem.text.length;
13740
13746
  if (index === 0) {
13741
- newMessageText = [textPart.substring(0, matchIndex), /*#__PURE__*/React__default.createElement("a", {
13747
+ newMessageText = [textPart.substring(0, matchIndex), /*#__PURE__*/React__default.createElement("a", Object.assign({
13742
13748
  draggable: false,
13743
13749
  key: index,
13744
- href: matchItem.url,
13750
+ href: isInviteLink ? undefined : matchItem.url,
13745
13751
  target: target,
13746
- rel: 'noreferrer'
13747
- }, "" + matchItem.text)];
13752
+ rel: 'noreferrer',
13753
+ style: {
13754
+ cursor: 'pointer'
13755
+ }
13756
+ }, isInviteLink ? {
13757
+ onClick: function onClick() {
13758
+ var splitedKey = matchItem.url.split('/');
13759
+ var key = splitedKey[splitedKey.length - 1];
13760
+ if (key) {
13761
+ onInviteLinkClick === null || onInviteLinkClick === void 0 ? void 0 : onInviteLinkClick(key);
13762
+ }
13763
+ }
13764
+ } : {}), "" + matchItem.text)];
13748
13765
  } else {
13749
13766
  newMessageText.push(textPart.substring(prevMatchEnd, matchIndex), /*#__PURE__*/React__default.createElement("a", {
13750
13767
  draggable: false,
13751
13768
  key: index,
13752
- href: matchItem.url,
13769
+ href: isInviteLink ? undefined : matchItem.url,
13753
13770
  target: target,
13754
13771
  rel: 'noreferrer'
13755
13772
  }, "" + matchItem.text));
@@ -13774,7 +13791,13 @@ var MessageTextFormat = function MessageTextFormat(_ref2) {
13774
13791
  shouldOpenUserProfileForMention = _ref2.shouldOpenUserProfileForMention,
13775
13792
  unsupportedMessage = _ref2.unsupportedMessage,
13776
13793
  _ref2$target = _ref2.target,
13777
- target = _ref2$target === void 0 ? '_blank' : _ref2$target;
13794
+ target = _ref2$target === void 0 ? '_blank' : _ref2$target,
13795
+ _ref2$isInviteLink = _ref2.isInviteLink,
13796
+ isInviteLink = _ref2$isInviteLink === void 0 ? false : _ref2$isInviteLink;
13797
+ var dispatch = useDispatch();
13798
+ var onInviteLinkClick = function onInviteLinkClick(key) {
13799
+ dispatch(getChannelByInviteKeyAC(key));
13800
+ };
13778
13801
  try {
13779
13802
  var messageText = [];
13780
13803
  var linkify = new LinkifyIt();
@@ -13792,12 +13815,12 @@ var MessageTextFormat = function MessageTextFormat(_ref2) {
13792
13815
  var firstPart = "" + (textPart ? textPart === null || textPart === void 0 ? void 0 : textPart.substring(nextPartIndex || 0, attributeOffset) : '');
13793
13816
  var firstPartMatch = firstPart ? linkify.match(firstPart) : '';
13794
13817
  if (!isLastMessage && !asSampleText && firstPartMatch) {
13795
- firstPart = linkifyTextPart(firstPart, firstPartMatch, target);
13818
+ firstPart = linkifyTextPart(firstPart, firstPartMatch, target, isInviteLink, onInviteLinkClick);
13796
13819
  }
13797
13820
  var secondPart = "" + (textPart ? textPart === null || textPart === void 0 ? void 0 : textPart.substring(attributeOffset + attribute.length) : '');
13798
13821
  var secondPartMatch = secondPart ? linkify.match(secondPart) : '';
13799
13822
  if (!isLastMessage && !asSampleText && secondPartMatch) {
13800
- secondPart = linkifyTextPart(secondPart, secondPartMatch, target);
13823
+ secondPart = linkifyTextPart(secondPart, secondPartMatch, target, isInviteLink, onInviteLinkClick);
13801
13824
  }
13802
13825
  if (attribute.type.includes('mention')) {
13803
13826
  var mentionDisplay = message.mentionedUsers && message.mentionedUsers.find(function (men) {
@@ -13866,7 +13889,7 @@ var MessageTextFormat = function MessageTextFormat(_ref2) {
13866
13889
  } else {
13867
13890
  var match = linkify.match(text);
13868
13891
  if (!isLastMessage && !asSampleText && match) {
13869
- messageText = linkifyTextPart(text, match, target);
13892
+ messageText = linkifyTextPart(text, match, target, isInviteLink, onInviteLinkClick);
13870
13893
  }
13871
13894
  }
13872
13895
  return messageText.length > 1 ? asSampleText ? messageText.join('') : messageText : text;
@@ -17660,6 +17683,7 @@ function getChannelByInviteKey(action) {
17660
17683
  _context33.n = 2;
17661
17684
  return effects.put(setJoinableChannelAC(JSON.parse(JSON.stringify(channel[0]))));
17662
17685
  case 2:
17686
+ window.history.pushState({}, '', window.location.pathname + '?join=' + key);
17663
17687
  _context33.n = 5;
17664
17688
  break;
17665
17689
  case 3:
@@ -22293,12 +22317,6 @@ var store = configureStore({
22293
22317
  });
22294
22318
  sagaMiddleware.run(rootSaga);
22295
22319
 
22296
- var SceytReduxContext = /*#__PURE__*/React__default.createContext(null);
22297
-
22298
- var useSelector = reactRedux.createSelectorHook(SceytReduxContext);
22299
- var useDispatch = reactRedux.createDispatchHook(SceytReduxContext);
22300
- var useStore = reactRedux.createStoreHook(SceytReduxContext);
22301
-
22302
22320
  var channelsSelector = function channelsSelector(store) {
22303
22321
  return store.ChannelReducer.channels;
22304
22322
  };
@@ -22884,6 +22902,7 @@ function JoinGroupPopup(_ref) {
22884
22902
  height: '12px',
22885
22903
  width: '12px'
22886
22904
  }), /*#__PURE__*/React__default.createElement(TopAvatar, null, /*#__PURE__*/React__default.createElement(Avatar, {
22905
+ key: channel.id,
22887
22906
  name: channel.subject || '',
22888
22907
  image: channel.avatar || '',
22889
22908
  size: 90,
@@ -22895,7 +22914,7 @@ function JoinGroupPopup(_ref) {
22895
22914
  color: textPrimary
22896
22915
  }, subtitleText), showMembersAvatars && (/*#__PURE__*/React__default.createElement(MembersRow, null, firstMembers.map(function (m, idx) {
22897
22916
  return /*#__PURE__*/React__default.createElement(MemberAvatar, {
22898
- key: m.id,
22917
+ key: m.id || "member-" + idx,
22899
22918
  index: idx,
22900
22919
  borderColor: background
22901
22920
  }, /*#__PURE__*/React__default.createElement(Avatar, {
@@ -34411,6 +34430,8 @@ var OGMetadata = function OGMetadata(_ref) {
34411
34430
  ogContainerMargin = _ref.ogContainerMargin,
34412
34431
  _ref$target = _ref.target,
34413
34432
  target = _ref$target === void 0 ? '_blank' : _ref$target,
34433
+ _ref$isInviteLink = _ref.isInviteLink,
34434
+ isInviteLink = _ref$isInviteLink === void 0 ? false : _ref$isInviteLink,
34414
34435
  metadataGetSuccessCallback = _ref.metadataGetSuccessCallback;
34415
34436
  var dispatch = useDispatch();
34416
34437
  var oGMetadata = useSelector(function (state) {
@@ -34688,7 +34709,14 @@ var OGMetadata = function OGMetadata(_ref) {
34688
34709
  alt: ''
34689
34710
  })))) : textContent;
34690
34711
  }, [hasImage, elements, shouldAnimate, ogContainerShowBackground, ogShowFavicon, faviconUrl, textContent]);
34691
- return /*#__PURE__*/React__default.createElement(OGMetadataContainer, {
34712
+ var getChannel = React.useCallback(function () {
34713
+ var splitedKey = attachment === null || attachment === void 0 ? void 0 : attachment.url.split('/');
34714
+ var key = splitedKey[splitedKey.length - 1];
34715
+ if (key) {
34716
+ dispatch(getChannelByInviteKeyAC(key));
34717
+ }
34718
+ }, [attachment === null || attachment === void 0 ? void 0 : attachment.url]);
34719
+ return /*#__PURE__*/React__default.createElement(OGMetadataContainer, Object.assign({
34692
34720
  showOGMetadata: !!showOGMetadata,
34693
34721
  bgColor: incoming ? incomingMessageBackgroundX : outgoingMessageBackgroundX,
34694
34722
  showBackground: ogContainerShowBackground,
@@ -34696,12 +34724,18 @@ var OGMetadata = function OGMetadata(_ref) {
34696
34724
  borderRadius: ogContainerBorderRadius,
34697
34725
  padding: ogContainerPadding,
34698
34726
  className: ogContainerClassName,
34699
- containerMargin: ogContainerMargin,
34727
+ containerMargin: ogContainerMargin
34728
+ }, isInviteLink ? {
34729
+ as: 'div',
34730
+ onClick: function onClick() {
34731
+ getChannel();
34732
+ }
34733
+ } : {
34700
34734
  as: 'a',
34701
34735
  href: attachment === null || attachment === void 0 ? void 0 : attachment.url,
34702
34736
  target: target,
34703
34737
  rel: target === '_blank' ? 'noopener noreferrer' : undefined
34704
- }, content);
34738
+ }), content);
34705
34739
  };
34706
34740
  var sharedKeyframes = "\n @keyframes fadeInSlideUp {\n from {\n opacity: 0;\n transform: translateY(10px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n @keyframes fadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n\n @keyframes expandHeight {\n from {\n max-height: 0;\n opacity: 0;\n }\n to {\n max-height: 1000px;\n opacity: 1;\n }\n }\n";
34707
34741
  var OGMetadataContainer = styled__default.div(_templateObject$F || (_templateObject$F = _taggedTemplateLiteralLoose(["\n min-width: inherit;\n max-width: inherit;\n width: 100%;\n display: grid;\n grid-template-columns: 1fr;\n background-color: ", ";\n border-radius: ", ";\n margin: ", ";\n // margin-bottom: ", ";\n padding: ", ";\n text-decoration: none;\n color: inherit;\n &:hover {\n opacity: 0.9;\n cursor: pointer;\n }\n"])), function (_ref2) {
@@ -35203,7 +35237,7 @@ var MessageBody = function MessageBody(_ref) {
35203
35237
  ogContainerShowBackground: ogMetadataProps === null || ogMetadataProps === void 0 ? void 0 : ogMetadataProps.ogContainerShowBackground,
35204
35238
  ogContainerBackground: ogMetadataProps === null || ogMetadataProps === void 0 ? void 0 : ogMetadataProps.ogContainerBackground,
35205
35239
  infoPadding: ogMetadataProps === null || ogMetadataProps === void 0 ? void 0 : ogMetadataProps.infoPadding
35206
- })), /*#__PURE__*/React__default.createElement("span", {
35240
+ })), message.type !== exports.MESSAGE_TYPE.POLL && (/*#__PURE__*/React__default.createElement("span", {
35207
35241
  ref: messageTextRef
35208
35242
  }, MessageTextFormat({
35209
35243
  text: message.body,
@@ -35215,7 +35249,7 @@ var MessageBody = function MessageBody(_ref) {
35215
35249
  onMentionNameClick: handleOpenUserProfile,
35216
35250
  shouldOpenUserProfileForMention: !!shouldOpenUserProfileForMention,
35217
35251
  unsupportedMessage: unsupportedMessage
35218
- })), !withAttachments && message.state === MESSAGE_STATUS.DELETE ? (/*#__PURE__*/React__default.createElement(MessageStatusDeleted$1, {
35252
+ }))), !withAttachments && message.state === MESSAGE_STATUS.DELETE ? (/*#__PURE__*/React__default.createElement(MessageStatusDeleted$1, {
35219
35253
  color: textSecondary
35220
35254
  }, " Message was deleted. ")) : '', !ogContainerFirst && linkAttachment && !mediaAttachment && !withMediaAttachment && !fileAttachment && (/*#__PURE__*/React__default.createElement(OGMetadata, {
35221
35255
  maxWidth: (ogMetadataProps === null || ogMetadataProps === void 0 ? void 0 : ogMetadataProps.maxWidth) || 400,
@@ -35238,7 +35272,8 @@ var MessageBody = function MessageBody(_ref) {
35238
35272
  ogContainerClassName: ogMetadataProps === null || ogMetadataProps === void 0 ? void 0 : ogMetadataProps.ogContainerClassName,
35239
35273
  ogContainerShowBackground: ogMetadataProps === null || ogMetadataProps === void 0 ? void 0 : ogMetadataProps.ogContainerShowBackground,
35240
35274
  ogContainerBackground: ogMetadataProps === null || ogMetadataProps === void 0 ? void 0 : ogMetadataProps.ogContainerBackground,
35241
- infoPadding: ogMetadataProps === null || ogMetadataProps === void 0 ? void 0 : ogMetadataProps.infoPadding
35275
+ infoPadding: ogMetadataProps === null || ogMetadataProps === void 0 ? void 0 : ogMetadataProps.infoPadding,
35276
+ isInviteLink: ogMetadataProps === null || ogMetadataProps === void 0 ? void 0 : ogMetadataProps.isInviteLink
35242
35277
  })), messageStatusAndTimePosition === 'onMessage' && !notLinkAttachment && (messageStatusVisible || messageTimeVisible) ? (/*#__PURE__*/React__default.createElement(MessageStatusAndTime$1, {
35243
35278
  message: message,
35244
35279
  showMessageTimeAndStatusOnlyOnHover: showMessageTimeAndStatusOnlyOnHover,
@@ -35299,7 +35334,7 @@ var MessageBody = function MessageBody(_ref) {
35299
35334
  channelId: message.channelId,
35300
35335
  incoming: message.incoming
35301
35336
  });
35302
- }), message.type === 'poll' && /*#__PURE__*/React__default.createElement(PollMessage, {
35337
+ }), message.type === exports.MESSAGE_TYPE.POLL && /*#__PURE__*/React__default.createElement(PollMessage, {
35303
35338
  message: message
35304
35339
  }), emojisPopupOpen && emojisPopupPosition && (/*#__PURE__*/React__default.createElement(EmojiContainer, {
35305
35340
  id: message.id + "_emoji_popup_container",
@@ -35970,23 +36005,7 @@ var Message$1 = function Message(_ref) {
35970
36005
  messageTextLineHeight = _ref.messageTextLineHeight,
35971
36006
  messageTimeColorOnAttachment = _ref.messageTimeColorOnAttachment,
35972
36007
  shouldOpenUserProfileForMention = _ref.shouldOpenUserProfileForMention,
35973
- _ref$ogMetadataProps = _ref.ogMetadataProps,
35974
- ogMetadataProps = _ref$ogMetadataProps === void 0 ? {
35975
- maxWidth: 400,
35976
- maxHeight: undefined,
35977
- ogLayoutOrder: 'link-first',
35978
- ogShowUrl: false,
35979
- ogShowTitle: true,
35980
- ogShowDescription: true,
35981
- ogShowFavicon: true,
35982
- order: {
35983
- image: 1,
35984
- title: 2,
35985
- description: 3,
35986
- link: 4
35987
- },
35988
- infoPadding: '0 8px'
35989
- } : _ref$ogMetadataProps,
36008
+ ogMetadataProps = _ref.ogMetadataProps,
35990
36009
  _ref$showInfoMessageP = _ref.showInfoMessageProps,
35991
36010
  showInfoMessageProps = _ref$showInfoMessageP === void 0 ? {} : _ref$showInfoMessageP;
35992
36011
  var _useColor = useColors(),
@@ -36918,23 +36937,7 @@ var MessageList = function MessageList(_ref2) {
36918
36937
  shouldOpenUserProfileForMention = _ref2.shouldOpenUserProfileForMention,
36919
36938
  _ref2$showInfoMessage = _ref2.showInfoMessageProps,
36920
36939
  showInfoMessageProps = _ref2$showInfoMessage === void 0 ? {} : _ref2$showInfoMessage,
36921
- _ref2$ogMetadataProps = _ref2.ogMetadataProps,
36922
- ogMetadataProps = _ref2$ogMetadataProps === void 0 ? {
36923
- maxWidth: 400,
36924
- maxHeight: undefined,
36925
- ogLayoutOrder: 'link-first',
36926
- ogShowUrl: false,
36927
- ogShowTitle: true,
36928
- ogShowDescription: true,
36929
- ogShowFavicon: true,
36930
- order: {
36931
- image: 1,
36932
- title: 2,
36933
- description: 3,
36934
- link: 4
36935
- },
36936
- infoPadding: '0 8px'
36937
- } : _ref2$ogMetadataProps;
36940
+ ogMetadataProps = _ref2.ogMetadataProps;
36938
36941
  var _useColor = useColors(),
36939
36942
  outgoingMessageBackground = _useColor[THEME_COLORS.OUTGOING_MESSAGE_BACKGROUND],
36940
36943
  themeBackgroundColor = _useColor[THEME_COLORS.BACKGROUND],
@@ -38027,7 +38030,8 @@ var MessagesContainer = function MessagesContainer(_ref) {
38027
38030
  description: 3,
38028
38031
  link: 4
38029
38032
  },
38030
- infoPadding: '0 8px'
38033
+ infoPadding: '0 8px',
38034
+ isInviteLink: false
38031
38035
  } : _ref$ogMetadataProps;
38032
38036
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MessageList, {
38033
38037
  fontFamily: fontFamily,
@@ -43690,145 +43694,24 @@ function InviteLinkModal(_ref) {
43690
43694
  };
43691
43695
  var handleForwardChannels = function handleForwardChannels(channelIds) {
43692
43696
  try {
43693
- if (!(channelIds !== null && channelIds !== void 0 && channelIds.length)) {
43694
- setOpenForwardPopup(false);
43695
- return Promise.resolve();
43696
- }
43697
- setOpenForwardPopup(false);
43698
- return Promise.resolve(_forOf(channelIds, function (channelId) {
43699
- var channel = getChannelFromMap(channelId);
43700
- var _temp3 = function () {
43701
- if (shareMode === 'link') {
43702
- var linkAttachmentBuilder = channel.createAttachmentBuilder(inviteUrl, attachmentTypes.link);
43703
- var linkAttachmentToSend = linkAttachmentBuilder.setName('Invite link').setUpload(false).create();
43704
- var message = {
43705
- metadata: '',
43706
- body: inviteUrl,
43707
- mentionedUsers: [],
43708
- type: 'text',
43709
- attachments: [linkAttachmentToSend]
43710
- };
43711
- dispatch(forwardMessageAC(message, channelId, connectionStatus, false));
43712
- } else {
43713
- var _temp2 = _catch(function () {
43714
- var toPngBlob = function toPngBlob() {
43715
- try {
43716
- var dpr = 4;
43717
- var baseQrSize = 200;
43718
- var qrSize = baseQrSize * dpr;
43719
- var qrUrl = "https://api.qrserver.com/v1/create-qr-code/?data=" + encodeURIComponent(inviteUrl) + "&size=" + qrSize + "x" + qrSize + "&ecc=H&margin=32&color=000000&bgcolor=FFFFFF";
43720
- return Promise.resolve(fetch(qrUrl, {
43721
- cache: 'no-store'
43722
- })).then(function (qrResp) {
43723
- return Promise.resolve(qrResp.blob()).then(function (qrBlob) {
43724
- var qrObjectUrl = URL.createObjectURL(qrBlob);
43725
- var boxWidth = qrSize;
43726
- var boxHeight = qrSize;
43727
- var canvas = document.createElement('canvas');
43728
- canvas.width = boxWidth;
43729
- canvas.height = boxHeight;
43730
- var ctx = canvas.getContext('2d');
43731
- var img = new Image();
43732
- img.src = qrObjectUrl;
43733
- return Promise.resolve(new Promise(function (resolve, reject) {
43734
- img.onload = function () {
43735
- return resolve(null);
43736
- };
43737
- img.onerror = reject;
43738
- })).then(function () {
43739
- var _logoRef$current;
43740
- function _temp6() {
43741
- URL.revokeObjectURL(qrObjectUrl);
43742
- return Promise.resolve(new Promise(function (resolve) {
43743
- return canvas.toBlob(function (b) {
43744
- return resolve(b);
43745
- }, 'image/png');
43746
- }));
43747
- }
43748
- ctx.imageSmoothingEnabled = false;
43749
- ctx.drawImage(img, 0, 0, qrSize, qrSize);
43750
- var overlaySize = qrSize * 22 / 100;
43751
- var overlayX = (boxWidth - overlaySize) / 2;
43752
- var overlayY = (boxHeight - overlaySize) / 2;
43753
- var roundedPath = function roundedPath(x, y, w, h, r) {
43754
- ctx.beginPath();
43755
- ctx.moveTo(x + r, y);
43756
- ctx.lineTo(x + w - r, y);
43757
- ctx.quadraticCurveTo(x + w, y, x + w, y + r);
43758
- ctx.lineTo(x + w, y + h - r);
43759
- ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
43760
- ctx.lineTo(x + r, y + h);
43761
- ctx.quadraticCurveTo(x, y + h, x, y + h - r);
43762
- ctx.lineTo(x, y + r);
43763
- ctx.quadraticCurveTo(x, y, x + r, y);
43764
- ctx.closePath();
43765
- };
43766
- var cornerRadius = 8 * dpr;
43767
- var imgElement = (_logoRef$current = logoRef.current) === null || _logoRef$current === void 0 ? void 0 : _logoRef$current.querySelector('img');
43768
- var _temp5 = function () {
43769
- if (imgElement && (imgElement.currentSrc || imgElement.src)) {
43770
- var logoUrl = imgElement.currentSrc || imgElement.src;
43771
- var logoImg = new Image();
43772
- logoImg.src = logoUrl;
43773
- return Promise.resolve(new Promise(function (resolve, reject) {
43774
- logoImg.onload = function () {
43775
- return resolve(null);
43776
- };
43777
- logoImg.onerror = reject;
43778
- })).then(function () {
43779
- ctx.save();
43780
- roundedPath(overlayX, overlayY, overlaySize, overlaySize, cornerRadius);
43781
- ctx.clip();
43782
- ctx.drawImage(logoImg, overlayX, overlayY, overlaySize, overlaySize);
43783
- ctx.restore();
43784
- });
43785
- } else {
43786
- var _logoRef$current2;
43787
- var svgElement = (_logoRef$current2 = logoRef.current) === null || _logoRef$current2 === void 0 ? void 0 : _logoRef$current2.querySelector('svg');
43788
- var _temp4 = function () {
43789
- if (svgElement) {
43790
- var serializer = new XMLSerializer();
43791
- var svgString = serializer.serializeToString(svgElement);
43792
- if (!/^<svg[^>]+xmlns=/.test(svgString)) {
43793
- svgString = svgString.replace('<svg', '<svg xmlns="http://www.w3.org/2000/svg"');
43794
- }
43795
- var svgBlob = new Blob([svgString], {
43796
- type: 'image/svg+xml;charset=utf-8'
43797
- });
43798
- var svgUrl = URL.createObjectURL(svgBlob);
43799
- var _logoImg = new Image();
43800
- _logoImg.src = svgUrl;
43801
- return Promise.resolve(new Promise(function (resolve, reject) {
43802
- _logoImg.onload = function () {
43803
- return resolve(null);
43804
- };
43805
- _logoImg.onerror = reject;
43806
- })).then(function () {
43807
- ctx.save();
43808
- roundedPath(overlayX, overlayY, overlaySize, overlaySize, cornerRadius);
43809
- ctx.clip();
43810
- ctx.drawImage(_logoImg, overlayX, overlayY, overlaySize, overlaySize);
43811
- ctx.restore();
43812
- URL.revokeObjectURL(svgUrl);
43813
- });
43814
- }
43815
- }();
43816
- if (_temp4 && _temp4.then) return _temp4.then(function () {});
43817
- }
43818
- }();
43819
- return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
43820
- });
43821
- });
43822
- });
43823
- } catch (e) {
43824
- return Promise.reject(e);
43825
- }
43697
+ var _temp5 = function _temp5() {
43698
+ return _forOf(channelIds, function (channelId) {
43699
+ var channel = getChannelFromMap(channelId);
43700
+ var _temp3 = function () {
43701
+ if (shareMode === 'link') {
43702
+ var linkAttachmentBuilder = channel.createAttachmentBuilder(inviteUrl, attachmentTypes.link);
43703
+ var linkAttachmentToSend = linkAttachmentBuilder.setName('Invite link').setUpload(false).create();
43704
+ var message = {
43705
+ metadata: '',
43706
+ body: inviteUrl,
43707
+ mentionedUsers: [],
43708
+ type: 'text',
43709
+ attachments: [linkAttachmentToSend]
43826
43710
  };
43827
- return Promise.resolve(toPngBlob()).then(function (blob) {
43828
- var file = new File([blob], 'invite-qr.png', {
43829
- type: 'image/png'
43830
- });
43831
- var localUrl = URL.createObjectURL(file);
43711
+ dispatch(forwardMessageAC(message, channelId, connectionStatus, false));
43712
+ } else {
43713
+ var _temp2 = _catch(function () {
43714
+ var _file, _file2, _file3, _file4;
43832
43715
  var message = {
43833
43716
  metadata: '',
43834
43717
  body: '',
@@ -43838,16 +43721,16 @@ function InviteLinkModal(_ref) {
43838
43721
  name: 'invite-qr.png',
43839
43722
  data: file,
43840
43723
  upload: false,
43841
- type: "" + file.type,
43724
+ type: "" + ((_file = file) === null || _file === void 0 ? void 0 : _file.type),
43842
43725
  url: {
43843
- type: "" + file.type,
43726
+ type: "" + ((_file2 = file) === null || _file2 === void 0 ? void 0 : _file2.type),
43844
43727
  data: file
43845
43728
  },
43846
43729
  createdAt: new Date(),
43847
43730
  progress: 0,
43848
43731
  completion: 0,
43849
43732
  messageId: '',
43850
- size: file.size,
43733
+ size: (_file3 = file) === null || _file3 === void 0 ? void 0 : _file3.size,
43851
43734
  attachmentUrl: localUrl
43852
43735
  }]
43853
43736
  };
@@ -43861,32 +43744,165 @@ function InviteLinkModal(_ref) {
43861
43744
  progress: 0,
43862
43745
  completion: 0,
43863
43746
  messageId: '',
43864
- size: file.size,
43747
+ size: ((_file4 = file) === null || _file4 === void 0 ? void 0 : _file4.size) || 0,
43865
43748
  attachmentUrl: localUrl
43866
43749
  }], message, channel)).then(function (attachmentsToSend) {
43867
43750
  dispatch(forwardMessageAC(_extends({}, message, {
43868
43751
  attachments: attachmentsToSend
43869
43752
  }), channelId, connectionStatus, false));
43870
43753
  });
43754
+ }, function (e) {
43755
+ console.log('error', e);
43756
+ var linkAttachmentBuilder = channel.createAttachmentBuilder(inviteUrl, attachmentTypes.link);
43757
+ var linkAttachmentToSend = linkAttachmentBuilder.setName('Invite link').setUpload(false).create();
43758
+ var message = {
43759
+ metadata: '',
43760
+ body: inviteUrl,
43761
+ mentionedUsers: [],
43762
+ type: 'text',
43763
+ attachments: [linkAttachmentToSend]
43764
+ };
43765
+ dispatch(forwardMessageAC(message, channelId, connectionStatus, false));
43871
43766
  });
43872
- }, function (e) {
43873
- console.log('error', e);
43874
- var linkAttachmentBuilder = channel.createAttachmentBuilder(inviteUrl, attachmentTypes.link);
43875
- var linkAttachmentToSend = linkAttachmentBuilder.setName('Invite link').setUpload(false).create();
43876
- var message = {
43877
- metadata: '',
43878
- body: inviteUrl,
43879
- mentionedUsers: [],
43880
- type: 'text',
43881
- attachments: [linkAttachmentToSend]
43882
- };
43883
- dispatch(forwardMessageAC(message, channelId, connectionStatus, false));
43767
+ if (_temp2 && _temp2.then) return _temp2.then(function () {});
43768
+ }
43769
+ }();
43770
+ if (_temp3 && _temp3.then) return _temp3.then(function () {});
43771
+ });
43772
+ };
43773
+ if (!(channelIds !== null && channelIds !== void 0 && channelIds.length)) {
43774
+ setOpenForwardPopup(false);
43775
+ return Promise.resolve();
43776
+ }
43777
+ setOpenForwardPopup(false);
43778
+ var file = null;
43779
+ var blob = null;
43780
+ var localUrl = '';
43781
+ var _temp4 = function () {
43782
+ if (shareMode === 'qr') {
43783
+ var toPngBlob = function toPngBlob() {
43784
+ try {
43785
+ var dpr = 4;
43786
+ var baseQrSize = 200;
43787
+ var qrSize = baseQrSize * dpr;
43788
+ var qrUrl = "https://api.qrserver.com/v1/create-qr-code/?data=" + encodeURIComponent(inviteUrl) + "&size=" + qrSize + "x" + qrSize + "&ecc=H&margin=32&color=000000&bgcolor=FFFFFF";
43789
+ return Promise.resolve(fetch(qrUrl, {
43790
+ cache: 'no-store'
43791
+ })).then(function (qrResp) {
43792
+ return Promise.resolve(qrResp.blob()).then(function (qrBlob) {
43793
+ var qrObjectUrl = URL.createObjectURL(qrBlob);
43794
+ var boxWidth = qrSize;
43795
+ var boxHeight = qrSize;
43796
+ var canvas = document.createElement('canvas');
43797
+ canvas.width = boxWidth;
43798
+ canvas.height = boxHeight;
43799
+ var ctx = canvas.getContext('2d');
43800
+ var img = new Image();
43801
+ img.src = qrObjectUrl;
43802
+ return Promise.resolve(new Promise(function (resolve, reject) {
43803
+ img.onload = function () {
43804
+ return resolve(null);
43805
+ };
43806
+ img.onerror = reject;
43807
+ })).then(function () {
43808
+ var _logoRef$current;
43809
+ function _temp8() {
43810
+ URL.revokeObjectURL(qrObjectUrl);
43811
+ return Promise.resolve(new Promise(function (resolve) {
43812
+ return canvas.toBlob(function (b) {
43813
+ return resolve(b);
43814
+ }, 'image/png');
43815
+ }));
43816
+ }
43817
+ ctx.imageSmoothingEnabled = false;
43818
+ ctx.drawImage(img, 0, 0, qrSize, qrSize);
43819
+ var overlaySize = qrSize * 22 / 100;
43820
+ var overlayX = (boxWidth - overlaySize) / 2;
43821
+ var overlayY = (boxHeight - overlaySize) / 2;
43822
+ var roundedPath = function roundedPath(x, y, w, h, r) {
43823
+ ctx.beginPath();
43824
+ ctx.moveTo(x + r, y);
43825
+ ctx.lineTo(x + w - r, y);
43826
+ ctx.quadraticCurveTo(x + w, y, x + w, y + r);
43827
+ ctx.lineTo(x + w, y + h - r);
43828
+ ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
43829
+ ctx.lineTo(x + r, y + h);
43830
+ ctx.quadraticCurveTo(x, y + h, x, y + h - r);
43831
+ ctx.lineTo(x, y + r);
43832
+ ctx.quadraticCurveTo(x, y, x + r, y);
43833
+ ctx.closePath();
43834
+ };
43835
+ var cornerRadius = 8 * dpr;
43836
+ var imgElement = (_logoRef$current = logoRef.current) === null || _logoRef$current === void 0 ? void 0 : _logoRef$current.querySelector('img');
43837
+ var _temp7 = function () {
43838
+ if (imgElement && (imgElement.currentSrc || imgElement.src)) {
43839
+ var logoUrl = imgElement.currentSrc || imgElement.src;
43840
+ var logoImg = new Image();
43841
+ logoImg.src = logoUrl;
43842
+ return Promise.resolve(new Promise(function (resolve, reject) {
43843
+ logoImg.onload = function () {
43844
+ return resolve(null);
43845
+ };
43846
+ logoImg.onerror = reject;
43847
+ })).then(function () {
43848
+ ctx.save();
43849
+ roundedPath(overlayX, overlayY, overlaySize, overlaySize, cornerRadius);
43850
+ ctx.clip();
43851
+ ctx.drawImage(logoImg, overlayX, overlayY, overlaySize, overlaySize);
43852
+ ctx.restore();
43853
+ });
43854
+ } else {
43855
+ var _logoRef$current2;
43856
+ var svgElement = (_logoRef$current2 = logoRef.current) === null || _logoRef$current2 === void 0 ? void 0 : _logoRef$current2.querySelector('svg');
43857
+ var _temp6 = function () {
43858
+ if (svgElement) {
43859
+ var serializer = new XMLSerializer();
43860
+ var svgString = serializer.serializeToString(svgElement);
43861
+ if (!/^<svg[^>]+xmlns=/.test(svgString)) {
43862
+ svgString = svgString.replace('<svg', '<svg xmlns="http://www.w3.org/2000/svg"');
43863
+ }
43864
+ var svgBlob = new Blob([svgString], {
43865
+ type: 'image/svg+xml;charset=utf-8'
43866
+ });
43867
+ var svgUrl = URL.createObjectURL(svgBlob);
43868
+ var _logoImg = new Image();
43869
+ _logoImg.src = svgUrl;
43870
+ return Promise.resolve(new Promise(function (resolve, reject) {
43871
+ _logoImg.onload = function () {
43872
+ return resolve(null);
43873
+ };
43874
+ _logoImg.onerror = reject;
43875
+ })).then(function () {
43876
+ ctx.save();
43877
+ roundedPath(overlayX, overlayY, overlaySize, overlaySize, cornerRadius);
43878
+ ctx.clip();
43879
+ ctx.drawImage(_logoImg, overlayX, overlayY, overlaySize, overlaySize);
43880
+ ctx.restore();
43881
+ URL.revokeObjectURL(svgUrl);
43882
+ });
43883
+ }
43884
+ }();
43885
+ if (_temp6 && _temp6.then) return _temp6.then(function () {});
43886
+ }
43887
+ }();
43888
+ return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
43889
+ });
43890
+ });
43891
+ });
43892
+ } catch (e) {
43893
+ return Promise.reject(e);
43894
+ }
43895
+ };
43896
+ return Promise.resolve(toPngBlob()).then(function (_toPngBlob) {
43897
+ blob = _toPngBlob;
43898
+ file = new File([blob], 'invite-qr.png', {
43899
+ type: 'image/png'
43884
43900
  });
43885
- if (_temp2 && _temp2.then) return _temp2.then(function () {});
43886
- }
43887
- }();
43888
- if (_temp3 && _temp3.then) return _temp3.then(function () {});
43889
- }));
43901
+ localUrl = URL.createObjectURL(file);
43902
+ });
43903
+ }
43904
+ }();
43905
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4));
43890
43906
  } catch (e) {
43891
43907
  return Promise.reject(e);
43892
43908
  }