@shopgate/pwa-common-commerce 7.34.0-beta.5 → 7.34.0-beta.6
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-common-commerce",
|
|
3
|
-
"version": "7.34.0-beta.
|
|
3
|
+
"version": "7.34.0-beta.6",
|
|
4
4
|
"description": "Commerce library for the Shopgate Connect PWA.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"reselect": "^4.1.8"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@shopgate/pwa-common": "7.34.0-beta.
|
|
27
|
-
"@shopgate/pwa-core": "7.34.0-beta.
|
|
26
|
+
"@shopgate/pwa-common": "7.34.0-beta.6",
|
|
27
|
+
"@shopgate/pwa-core": "7.34.0-beta.6",
|
|
28
28
|
"@types/lodash": "^4.17.25",
|
|
29
29
|
"lodash": "^4.18.1",
|
|
30
30
|
"react": "^17.0.2",
|
package/reviews/streams/index.js
CHANGED
|
@@ -3,6 +3,8 @@ import { RESET_APP } from '@shopgate/pwa-common/constants/ActionTypes';
|
|
|
3
3
|
import { RESET_APP_REDUCERS } from '@shopgate/pwa-common/constants/Configuration';
|
|
4
4
|
import configuration from '@shopgate/pwa-common/collections/Configuration';
|
|
5
5
|
import { routeWillEnter$, routeWillLeave$ } from '@shopgate/pwa-common/streams/router';
|
|
6
|
+
import { RECEIVE_APP_SETTINGS } from '@shopgate/engage/settings/constants/appSettings';
|
|
7
|
+
import { getShowReviews } from '@shopgate/engage/settings/selectors/appSettings';
|
|
6
8
|
import { ITEM_PATH, RECEIVE_PRODUCT, RECEIVE_PRODUCT_CACHED } from '@shopgate/pwa-common-commerce/product/constants';
|
|
7
9
|
import { REQUEST_SUBMIT_REVIEW, RECEIVE_SUBMIT_REVIEW, ERROR_SUBMIT_REVIEW, RESET_SUBMIT_REVIEW } from "../constants";
|
|
8
10
|
export const reviewsWillEnter$ = routeWillEnter$.filter(({
|
|
@@ -60,4 +62,14 @@ export const reviewsDidReset$ = main$.filter(({
|
|
|
60
62
|
}
|
|
61
63
|
const resetReducers = action.reducers || configuration.get(RESET_APP_REDUCERS);
|
|
62
64
|
return Array.isArray(resetReducers) && resetReducers.includes('reviews');
|
|
63
|
-
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Gets triggered when received app settings switch the reviews on.
|
|
69
|
+
* @type {Observable}
|
|
70
|
+
*/
|
|
71
|
+
export const reviewsDidEnable$ = main$.filter(({
|
|
72
|
+
action,
|
|
73
|
+
prevState,
|
|
74
|
+
getState
|
|
75
|
+
}) => action.type === RECEIVE_APP_SETTINGS && !getShowReviews(prevState) && getShowReviews(getState()));
|
|
@@ -1,32 +1,44 @@
|
|
|
1
|
-
import appConfig from '@shopgate/pwa-common/helpers/config';
|
|
2
1
|
import { appWillStart$ } from '@shopgate/engage/core/streams';
|
|
2
|
+
import { getShowReviews } from '@shopgate/engage/settings/selectors/appSettings';
|
|
3
3
|
import fetchProductReviews from "../actions/fetchProductReviews";
|
|
4
4
|
import fetchProductReviewSettings from "../actions/fetchProductReviewSettings";
|
|
5
5
|
import { REVIEW_PREVIEW_COUNT } from "../constants";
|
|
6
|
-
import { reviewsDidReset$, shouldFetchReviews$ } from "../streams";
|
|
6
|
+
import { reviewsDidEnable$, reviewsDidReset$, shouldFetchReviews$ } from "../streams";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Review subscriptions.
|
|
10
10
|
* @param {Function} subscribe The subscribe function.
|
|
11
11
|
*/
|
|
12
12
|
export default function product(subscribe) {
|
|
13
|
-
if (!appConfig.hasReviews) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
13
|
subscribe(appWillStart$, ({
|
|
17
|
-
dispatch
|
|
14
|
+
dispatch,
|
|
15
|
+
getState
|
|
18
16
|
}) => {
|
|
19
|
-
|
|
17
|
+
if (getShowReviews(getState())) {
|
|
18
|
+
dispatch(fetchProductReviewSettings());
|
|
19
|
+
}
|
|
20
20
|
});
|
|
21
21
|
subscribe(reviewsDidReset$, ({
|
|
22
|
+
dispatch,
|
|
23
|
+
getState
|
|
24
|
+
}) => {
|
|
25
|
+
if (getShowReviews(getState())) {
|
|
26
|
+
dispatch(fetchProductReviewSettings());
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
subscribe(reviewsDidEnable$, ({
|
|
22
30
|
dispatch
|
|
23
31
|
}) => {
|
|
24
32
|
dispatch(fetchProductReviewSettings());
|
|
25
33
|
});
|
|
26
34
|
subscribe(shouldFetchReviews$, ({
|
|
27
35
|
action,
|
|
28
|
-
dispatch
|
|
36
|
+
dispatch,
|
|
37
|
+
getState
|
|
29
38
|
}) => {
|
|
39
|
+
if (!getShowReviews(getState())) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
30
42
|
dispatch(fetchProductReviewSettings());
|
|
31
43
|
if (action.productData) {
|
|
32
44
|
const {
|