@pushwoosh/smart-components-kit 1.0.38 → 1.0.40

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.
@@ -29,7 +29,7 @@ export const OpenActionsSummary = ({
29
29
  code: applicationCode
30
30
  }), [applicationCode]);
31
31
  const hasCustomPlatformsDeeplink = Object.keys(platformsDeeplinkUrls).length > 0;
32
- const safariUrl = !hasCustomPlatformsDeeplink && getSafariUrl(((_applicationData$valu = applicationData.value) === null || _applicationData$valu === void 0 ? void 0 : _applicationData$valu.application) || null, safariUrlArgs ?? '');
32
+ const safariUrl = getSafariUrl(((_applicationData$valu = applicationData.value) === null || _applicationData$valu === void 0 ? void 0 : _applicationData$valu.application) || null, safariUrlArgs ?? '');
33
33
  const renderInfoBlock = (device, action, url = null) => React.createElement(Vertical, null, React.createElement("span", null, "For", ' ', React.createElement("strong", null, device), ' ', "subscribers:", ' ', React.createElement("strong", null, action)), url && React.createElement(LinkRow, null, React.createElement(Link, {
34
34
  as: Tag.A,
35
35
  rel: "noopener noreferrer",
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useEffect, useState } from 'react';
2
2
  import { useToast } from '@pushwoosh/dumb-components';
3
3
  import { useSPAContext } from '../context';
4
- import { formatDeeplink } from './helpers';
4
+ import { formatDeeplink, isWebLink } from './helpers';
5
5
  const WEB_PLATFORM_KEY = 0;
6
6
  export const usePresetOpenActions = pushPreset => {
7
7
  const [openActions, setOpenActions] = useState(undefined);
@@ -25,13 +25,10 @@ export const usePresetOpenActions = pushPreset => {
25
25
  return '';
26
26
  }
27
27
  }, [openToast, rpcGateway]);
28
- const getOpenActionsByPreset = useCallback(async () => {
28
+ const getOpenActionsFromV2Preset = useCallback(async pushPreset => {
29
29
  var _pushPreset$localized, _pushPreset$openActio, _pushPreset$openActio2;
30
- if (!pushPreset) {
31
- return;
32
- }
33
30
  const safariUrlArgs = ((_pushPreset$localized = pushPreset.localizedProperties.default) === null || _pushPreset$localized === void 0 || (_pushPreset$localized = _pushPreset$localized.safari) === null || _pushPreset$localized === void 0 || (_pushPreset$localized = _pushPreset$localized.urlArguments) === null || _pushPreset$localized === void 0 ? void 0 : _pushPreset$localized[0]) ?? null;
34
- const webPageUrl = pushPreset.url;
31
+ const webPageUrl = isWebLink(pushPreset.url) ? pushPreset.url : null;
35
32
  const {
36
33
  platformsDeeplinkUrls,
37
34
  showRichmedia
@@ -46,18 +43,25 @@ export const usePresetOpenActions = pushPreset => {
46
43
  const deeplinkManual = pushPreset.openAction.kind.data;
47
44
  defaultDeeplinkUrl = deeplinkManual.url;
48
45
  }
46
+ return {
47
+ webPageUrl,
48
+ defaultDeeplinkUrl,
49
+ platformsDeeplinkUrls,
50
+ safariUrlArgs,
51
+ showRichmedia
52
+ };
53
+ }, [getDeeplinkUrl]);
54
+ const getOpenActionsByPreset = useCallback(async () => {
55
+ if (!pushPreset) {
56
+ return;
57
+ }
58
+ const openActions = pushPreset.isV2 ? await getOpenActionsFromV2Preset(pushPreset) : await getOpenActionsFromV1Preset(pushPreset);
49
59
  // setTimeout нужен, чтобы не получать ошибку 'ResizeObserver loop completed with undelivered notifications.'
50
60
  // Она возникает, когда этот хук вызывается ВНУТРИ Modal и с пересчетом её размера. Подробности в тикете FRONT-750
51
61
  setTimeout(() => {
52
- setOpenActions({
53
- webPageUrl,
54
- defaultDeeplinkUrl,
55
- platformsDeeplinkUrls,
56
- safariUrlArgs,
57
- showRichmedia
58
- });
62
+ setOpenActions(openActions);
59
63
  }, 0);
60
- }, [getDeeplinkUrl, pushPreset]);
64
+ }, [getOpenActionsFromV2Preset, pushPreset]);
61
65
  useEffect(() => {
62
66
  getOpenActionsByPreset();
63
67
  }, [getOpenActionsByPreset]);
@@ -93,4 +97,20 @@ const getPlatformDeeplinksByOpenActions = async (pushPreset, getDeeplinkUrl) =>
93
97
  platformsDeeplinkUrls,
94
98
  showRichmedia
95
99
  };
100
+ };
101
+ const getOpenActionsFromV1Preset = async pushPreset => {
102
+ var _pushPreset$localized2, _pushPreset$localized3;
103
+ const webPageUrl = !pushPreset.deeplink && isWebLink(pushPreset.url) ? pushPreset.url : null;
104
+ const defaultDeeplinkUrl = pushPreset.deeplink && pushPreset.url ? pushPreset.url : null;
105
+ const showRichmedia = pushPreset.richmedia ? {
106
+ code: pushPreset.richmedia
107
+ } : null;
108
+ const safariUrlArgs = ((_pushPreset$localized2 = pushPreset.localizedProperties.default) === null || _pushPreset$localized2 === void 0 || (_pushPreset$localized2 = _pushPreset$localized2.safari) === null || _pushPreset$localized2 === void 0 || (_pushPreset$localized2 = _pushPreset$localized2.urlArguments) === null || _pushPreset$localized2 === void 0 ? void 0 : _pushPreset$localized2[0]) ?? ((_pushPreset$localized3 = pushPreset.localizedProperties.en) === null || _pushPreset$localized3 === void 0 || (_pushPreset$localized3 = _pushPreset$localized3.safari) === null || _pushPreset$localized3 === void 0 || (_pushPreset$localized3 = _pushPreset$localized3.urlArguments) === null || _pushPreset$localized3 === void 0 ? void 0 : _pushPreset$localized3[0]) ?? null;
109
+ return {
110
+ webPageUrl,
111
+ defaultDeeplinkUrl,
112
+ platformsDeeplinkUrls: {},
113
+ safariUrlArgs,
114
+ showRichmedia
115
+ };
96
116
  };
package/package.json CHANGED
@@ -51,5 +51,5 @@
51
51
  "engines": {
52
52
  "node": ">= 18"
53
53
  },
54
- "version": "1.0.38"
54
+ "version": "1.0.40"
55
55
  }