@pushwoosh/smart-components-kit 1.0.39 → 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.
|
@@ -25,11 +25,8 @@ export const usePresetOpenActions = pushPreset => {
|
|
|
25
25
|
return '';
|
|
26
26
|
}
|
|
27
27
|
}, [openToast, rpcGateway]);
|
|
28
|
-
const
|
|
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
31
|
const webPageUrl = isWebLink(pushPreset.url) ? pushPreset.url : null;
|
|
35
32
|
const {
|
|
@@ -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
|
-
}, [
|
|
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