@twreporter/redux 8.0.2 → 8.0.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/CHANGELOG.md +16 -0
- package/lib/actions/analytics.js +9 -22
- package/lib/actions/auth.js +9 -28
- package/lib/actions/author-articles.js +14 -43
- package/lib/actions/author-details.js +3 -23
- package/lib/actions/authors.js +13 -53
- package/lib/actions/bookmarks.js +26 -54
- package/lib/actions/donation-history.js +5 -23
- package/lib/actions/error-action-creators.js +7 -22
- package/lib/actions/footprints.js +5 -22
- package/lib/actions/index-page.js +9 -26
- package/lib/actions/index.js +2 -18
- package/lib/actions/latest.js +9 -26
- package/lib/actions/post-reviews.js +4 -16
- package/lib/actions/posts.js +28 -82
- package/lib/actions/topics.js +31 -64
- package/lib/actions/user.js +5 -26
- package/lib/component/provider.js +7 -31
- package/lib/constants/action-types.js +2 -4
- package/lib/constants/api-config.js +2 -3
- package/lib/constants/api-endpoints.js +2 -3
- package/lib/constants/author-page.js +3 -7
- package/lib/constants/authors-list.js +3 -7
- package/lib/constants/http-protocol.js +2 -3
- package/lib/constants/latest.js +1 -2
- package/lib/constants/mobile-mockup-specification.js +10 -9
- package/lib/constants/post-styles.js +2 -3
- package/lib/constants/redux-state-field-names.js +13 -11
- package/lib/context/redux-store.js +1 -6
- package/lib/index.js +2 -24
- package/lib/reducers/analytics.js +6 -20
- package/lib/reducers/auth.js +2 -13
- package/lib/reducers/author-articles.js +10 -26
- package/lib/reducers/authors.js +5 -28
- package/lib/reducers/bookmark-widget.js +0 -11
- package/lib/reducers/bookmarks.js +9 -40
- package/lib/reducers/donation-history.js +11 -39
- package/lib/reducers/entities-for-authors.js +2 -10
- package/lib/reducers/entities.js +24 -94
- package/lib/reducers/feature-topic.js +3 -16
- package/lib/reducers/footprints.js +8 -20
- package/lib/reducers/index-page.js +2 -23
- package/lib/reducers/index.js +5 -29
- package/lib/reducers/latest.js +2 -13
- package/lib/reducers/origins.js +0 -7
- package/lib/reducers/post-reviews.js +6 -16
- package/lib/reducers/posts.js +6 -36
- package/lib/reducers/related-posts-of.js +12 -55
- package/lib/reducers/settings.js +0 -9
- package/lib/reducers/topics.js +11 -35
- package/lib/reducers/user.js +6 -33
- package/lib/schemas/article-schema.js +3 -7
- package/lib/store/bind-actions-to-store.js +4 -21
- package/lib/store/create-store.js +22 -22
- package/lib/typedef.js +2 -25
- package/lib/utils/__tests__/denormalize-asset.test.js +1 -1
- package/lib/utils/denormalize-asset.js +3 -23
- package/lib/utils/detect-env.js +2 -6
- package/lib/utils/error.js +9 -55
- package/lib/utils/image-processor.js +3 -9
- package/lib/utils/jwt.js +3 -10
- package/lib/utils/pagination.js +5 -9
- package/lib/utils/url.js +0 -6
- package/package.json +5 -4
package/lib/actions/user.js
CHANGED
|
@@ -6,30 +6,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getUserData = getUserData;
|
|
7
7
|
exports.onboarding = onboarding;
|
|
8
8
|
exports.setUserData = setUserData;
|
|
9
|
-
|
|
10
9
|
var _url = require("../utils/url");
|
|
11
|
-
|
|
12
10
|
var _apiConfig = _interopRequireDefault(require("../constants/api-config"));
|
|
13
|
-
|
|
14
11
|
var _apiEndpoints = _interopRequireDefault(require("../constants/api-endpoints"));
|
|
15
|
-
|
|
16
12
|
var _errorActionCreators = _interopRequireDefault(require("./error-action-creators"));
|
|
17
|
-
|
|
18
13
|
var _reduxStateFieldNames = _interopRequireDefault(require("../constants/redux-state-field-names"));
|
|
19
|
-
|
|
20
14
|
var _actionTypes = _interopRequireDefault(require("../constants/action-types"));
|
|
21
|
-
|
|
22
15
|
var _axios = _interopRequireDefault(require("axios"));
|
|
23
|
-
|
|
24
16
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
25
|
-
|
|
26
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
27
|
-
|
|
28
18
|
// lodash
|
|
19
|
+
|
|
29
20
|
var _ = {
|
|
30
21
|
get: _get["default"]
|
|
31
22
|
};
|
|
32
23
|
var apiTimeout = _apiConfig["default"].timeout;
|
|
24
|
+
|
|
33
25
|
/**
|
|
34
26
|
* @typedef {Object} userData
|
|
35
27
|
* @property {string} email - email of user
|
|
@@ -59,7 +51,6 @@ var apiTimeout = _apiConfig["default"].timeout;
|
|
|
59
51
|
* @param {string} actionType
|
|
60
52
|
* @returns {SuccessAction}
|
|
61
53
|
*/
|
|
62
|
-
|
|
63
54
|
function buildSuccessActionFromRes(axiosResponse, actionType) {
|
|
64
55
|
return {
|
|
65
56
|
type: actionType,
|
|
@@ -69,6 +60,7 @@ function buildSuccessActionFromRes(axiosResponse, actionType) {
|
|
|
69
60
|
}
|
|
70
61
|
};
|
|
71
62
|
}
|
|
63
|
+
|
|
72
64
|
/**
|
|
73
65
|
* @typedef {Object} FailAction
|
|
74
66
|
* @property {string} type - Action error type
|
|
@@ -86,8 +78,6 @@ function buildSuccessActionFromRes(axiosResponse, actionType) {
|
|
|
86
78
|
* @param {number} userID - id of user
|
|
87
79
|
* @return {Function} - function will be executed in Redux Thunk middleware
|
|
88
80
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
81
|
function getUserData(jwt, userID) {
|
|
92
82
|
/**
|
|
93
83
|
* @param {Function} dispatch - Redux store dispatch function
|
|
@@ -96,9 +86,7 @@ function getUserData(jwt, userID) {
|
|
|
96
86
|
*/
|
|
97
87
|
return function (dispatch, getState) {
|
|
98
88
|
var state = getState();
|
|
99
|
-
|
|
100
89
|
var apiOrigin = _.get(state, [_reduxStateFieldNames["default"].origins, 'api']);
|
|
101
|
-
|
|
102
90
|
var url = (0, _url.formURL)(apiOrigin, "/v2/".concat(_apiEndpoints["default"].users, "/").concat(userID));
|
|
103
91
|
dispatch({
|
|
104
92
|
type: _actionTypes["default"].user.read.request,
|
|
@@ -116,12 +104,12 @@ function getUserData(jwt, userID) {
|
|
|
116
104
|
return successAction;
|
|
117
105
|
})["catch"](function (error) {
|
|
118
106
|
var failAction = _errorActionCreators["default"].axios(error, _actionTypes["default"].user.read.failure);
|
|
119
|
-
|
|
120
107
|
dispatch(failAction);
|
|
121
108
|
return Promise.reject(failAction);
|
|
122
109
|
});
|
|
123
110
|
};
|
|
124
111
|
}
|
|
112
|
+
|
|
125
113
|
/**
|
|
126
114
|
* @export
|
|
127
115
|
* @param {string} jwt - access_token granted for the user
|
|
@@ -130,8 +118,6 @@ function getUserData(jwt, userID) {
|
|
|
130
118
|
* @param {string[]} maillist - subscribed mail list
|
|
131
119
|
* @return {Function} - function will be executed in Redux Thunk middleware
|
|
132
120
|
*/
|
|
133
|
-
|
|
134
|
-
|
|
135
121
|
function setUserData(jwt, userID, readPreference, maillist) {
|
|
136
122
|
/**
|
|
137
123
|
* @param {Function} dispatch - Redux store dispatch function
|
|
@@ -140,9 +126,7 @@ function setUserData(jwt, userID, readPreference, maillist) {
|
|
|
140
126
|
*/
|
|
141
127
|
return function (dispatch, getState) {
|
|
142
128
|
var state = getState();
|
|
143
|
-
|
|
144
129
|
var apiOrigin = _.get(state, [_reduxStateFieldNames["default"].origins, 'api']);
|
|
145
|
-
|
|
146
130
|
var url = (0, _url.formURL)(apiOrigin, "/v2/".concat(_apiEndpoints["default"].users, "/").concat(userID));
|
|
147
131
|
dispatch({
|
|
148
132
|
type: _actionTypes["default"].user.update.request,
|
|
@@ -164,12 +148,12 @@ function setUserData(jwt, userID, readPreference, maillist) {
|
|
|
164
148
|
return successAction;
|
|
165
149
|
})["catch"](function (error) {
|
|
166
150
|
var failAction = _errorActionCreators["default"].axios(error, _actionTypes["default"].user.update.failure);
|
|
167
|
-
|
|
168
151
|
dispatch(failAction);
|
|
169
152
|
return Promise.reject(failAction);
|
|
170
153
|
});
|
|
171
154
|
};
|
|
172
155
|
}
|
|
156
|
+
|
|
173
157
|
/**
|
|
174
158
|
* @export
|
|
175
159
|
* @param {string} jwt - access_token granted for the user
|
|
@@ -179,8 +163,6 @@ function setUserData(jwt, userID, readPreference, maillist) {
|
|
|
179
163
|
* @param {string} destination - redirect destination
|
|
180
164
|
* @return {Function} - function will be executed in Redux Thunk middleware
|
|
181
165
|
*/
|
|
182
|
-
|
|
183
|
-
|
|
184
166
|
function onboarding(jwt, userID, readPreference, maillist, destination) {
|
|
185
167
|
/**
|
|
186
168
|
* @param {Function} dispatch - Redux store dispatch function
|
|
@@ -189,9 +171,7 @@ function onboarding(jwt, userID, readPreference, maillist, destination) {
|
|
|
189
171
|
*/
|
|
190
172
|
return function (dispatch, getState) {
|
|
191
173
|
var state = getState();
|
|
192
|
-
|
|
193
174
|
var apiOrigin = _.get(state, [_reduxStateFieldNames["default"].origins, 'api']);
|
|
194
|
-
|
|
195
175
|
var url = (0, _url.formURL)(apiOrigin, "/v2/".concat(_apiEndpoints["default"].onboarding, "/").concat(userID), {
|
|
196
176
|
destination: destination
|
|
197
177
|
});
|
|
@@ -216,7 +196,6 @@ function onboarding(jwt, userID, readPreference, maillist, destination) {
|
|
|
216
196
|
return successAction;
|
|
217
197
|
})["catch"](function (error) {
|
|
218
198
|
var failAction = _errorActionCreators["default"].axios(error, _actionTypes["default"].user.update.failure);
|
|
219
|
-
|
|
220
199
|
dispatch(failAction);
|
|
221
200
|
return Promise.reject(failAction);
|
|
222
201
|
});
|
|
@@ -1,61 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _reduxStore = _interopRequireDefault(require("../context/redux-store"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
22
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
-
|
|
24
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
25
|
-
|
|
15
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
26
16
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
27
|
-
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
28
19
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
29
|
-
|
|
30
20
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
31
|
-
|
|
32
21
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
33
|
-
|
|
34
22
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
35
|
-
|
|
36
23
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
|
-
|
|
38
24
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
|
-
|
|
40
25
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
|
-
|
|
42
26
|
var Provider = /*#__PURE__*/function (_PureComponent) {
|
|
43
27
|
_inherits(Provider, _PureComponent);
|
|
44
|
-
|
|
45
28
|
var _super = _createSuper(Provider);
|
|
46
|
-
|
|
47
29
|
function Provider(props) {
|
|
48
30
|
var _this;
|
|
49
|
-
|
|
50
31
|
_classCallCheck(this, Provider);
|
|
51
|
-
|
|
52
32
|
_this = _super.call(this, props);
|
|
53
33
|
var store = _this.props.store;
|
|
54
34
|
_this.state = store.getState();
|
|
55
35
|
_this.unsubscribe = store.subscribe(_this.saveStoreStateToDetectStateChange.bind(_assertThisInitialized(_this)));
|
|
56
36
|
return _this;
|
|
57
37
|
}
|
|
58
|
-
|
|
59
38
|
_createClass(Provider, [{
|
|
60
39
|
key: "saveStoreStateToDetectStateChange",
|
|
61
40
|
value: function saveStoreStateToDetectStateChange() {
|
|
@@ -81,10 +60,8 @@ var Provider = /*#__PURE__*/function (_PureComponent) {
|
|
|
81
60
|
}, this.props.children);
|
|
82
61
|
}
|
|
83
62
|
}]);
|
|
84
|
-
|
|
85
63
|
return Provider;
|
|
86
64
|
}(_react.PureComponent);
|
|
87
|
-
|
|
88
65
|
Provider.propTypes = {
|
|
89
66
|
store: _propTypes["default"].shape({
|
|
90
67
|
subscribe: _propTypes["default"].func.isRequired,
|
|
@@ -93,5 +70,4 @@ Provider.propTypes = {
|
|
|
93
70
|
}),
|
|
94
71
|
children: _propTypes["default"].any
|
|
95
72
|
};
|
|
96
|
-
var _default = Provider;
|
|
97
|
-
exports["default"] = _default;
|
|
73
|
+
var _default = exports["default"] = Provider;
|
|
@@ -4,13 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
var _default = {
|
|
7
|
+
var _default = exports["default"] = {
|
|
8
8
|
// auth
|
|
9
9
|
REQUEST_AUTH: 'request_authorization',
|
|
10
10
|
AUTH_SUCCESS: 'grant_authorization_success',
|
|
11
11
|
AUTH_FAILURE: 'grant_authorization_failure',
|
|
12
12
|
AUTH_CLEAR: 'clear_authorization',
|
|
13
|
-
|
|
14
13
|
/**
|
|
15
14
|
* @deprecated
|
|
16
15
|
* keep these three action types here for backward compatibility.
|
|
@@ -186,5 +185,4 @@ var _default = {
|
|
|
186
185
|
failure: 'fail to fetch post reviews'
|
|
187
186
|
}
|
|
188
187
|
}
|
|
189
|
-
};
|
|
190
|
-
exports["default"] = _default;
|
|
188
|
+
};
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
var _default = {
|
|
7
|
+
var _default = exports["default"] = {
|
|
8
8
|
topics: 'topics',
|
|
9
9
|
indexPage: 'index_page',
|
|
10
10
|
indexPageCategories: 'index_page_categories',
|
|
@@ -15,5 +15,4 @@ var _default = {
|
|
|
15
15
|
onboarding: 'onboarding',
|
|
16
16
|
periodicDonations: 'periodic-donations',
|
|
17
17
|
postReviews: 'post_reviews'
|
|
18
|
-
};
|
|
19
|
-
exports["default"] = _default;
|
|
18
|
+
};
|
|
@@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.RETURN_DELAY_TIME = exports.NUMBER_OF_FIRST_RESPONSE_PAGE = exports.MAX_ARTICLES_PER_FETCH = void 0;
|
|
7
|
-
var NUMBER_OF_FIRST_RESPONSE_PAGE = 0;
|
|
8
|
-
exports.
|
|
9
|
-
var
|
|
10
|
-
exports.MAX_ARTICLES_PER_FETCH = MAX_ARTICLES_PER_FETCH;
|
|
11
|
-
var RETURN_DELAY_TIME = 1000; // ms
|
|
12
|
-
|
|
13
|
-
exports.RETURN_DELAY_TIME = RETURN_DELAY_TIME;
|
|
7
|
+
var NUMBER_OF_FIRST_RESPONSE_PAGE = exports.NUMBER_OF_FIRST_RESPONSE_PAGE = 0;
|
|
8
|
+
var MAX_ARTICLES_PER_FETCH = exports.MAX_ARTICLES_PER_FETCH = 5;
|
|
9
|
+
var RETURN_DELAY_TIME = exports.RETURN_DELAY_TIME = 1000; // ms
|
|
@@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.RETURN_DELAY_TIME = exports.NUMBER_OF_FIRST_RESPONSE_PAGE = exports.MAX_RESULTS_PER_FETCH = void 0;
|
|
7
|
-
var NUMBER_OF_FIRST_RESPONSE_PAGE = 0;
|
|
8
|
-
exports.
|
|
9
|
-
var
|
|
10
|
-
exports.MAX_RESULTS_PER_FETCH = MAX_RESULTS_PER_FETCH;
|
|
11
|
-
var RETURN_DELAY_TIME = 1000; // ms
|
|
12
|
-
|
|
13
|
-
exports.RETURN_DELAY_TIME = RETURN_DELAY_TIME;
|
|
7
|
+
var NUMBER_OF_FIRST_RESPONSE_PAGE = exports.NUMBER_OF_FIRST_RESPONSE_PAGE = 0;
|
|
8
|
+
var MAX_RESULTS_PER_FETCH = exports.MAX_RESULTS_PER_FETCH = 24;
|
|
9
|
+
var RETURN_DELAY_TIME = exports.RETURN_DELAY_TIME = 1000; // ms
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
var _default = {
|
|
7
|
+
var _default = exports["default"] = {
|
|
8
8
|
statusCode: {
|
|
9
9
|
ok: 200,
|
|
10
10
|
created: 201,
|
|
@@ -21,5 +21,4 @@ var _default = {
|
|
|
21
21
|
put: 'put',
|
|
22
22
|
options: 'options'
|
|
23
23
|
}
|
|
24
|
-
};
|
|
25
|
-
exports["default"] = _default;
|
|
24
|
+
};
|
package/lib/constants/latest.js
CHANGED
|
@@ -7,19 +7,20 @@ exports.itemWidthPct = exports.itemPlusPaddingWidthPct = exports.itemPaddingRigh
|
|
|
7
7
|
// 320 is iPhone5 width and also the mockup max-width,
|
|
8
8
|
// 238 is the item width in device.
|
|
9
9
|
// 26 is the padding between each item
|
|
10
|
+
|
|
10
11
|
var itemWidth = 238;
|
|
11
12
|
var itemPaddingRight = 26;
|
|
12
13
|
var mockupWidth = 320;
|
|
13
|
-
var firstItemMarginLeft = 42;
|
|
14
|
+
var firstItemMarginLeft = 42;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
// item width pct of mobiel device
|
|
17
|
+
var itemWidthPct = exports.itemWidthPct = "".concat(itemWidth / mockupWidth * 100);
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
var itemPlusPaddingWidthPct = "".concat((itemWidth + itemPaddingRight) / mockupWidth * 100);
|
|
19
|
+
// item + padding width pct
|
|
20
|
+
var itemPlusPaddingWidthPct = exports.itemPlusPaddingWidthPct = "".concat((itemWidth + itemPaddingRight) / mockupWidth * 100);
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
var firstItemMarginLeftPct = "".concat(firstItemMarginLeft / mockupWidth * 100);
|
|
22
|
+
// First item has 42px margin-left in mockup.
|
|
23
|
+
var firstItemMarginLeftPct = exports.firstItemMarginLeftPct = "".concat(firstItemMarginLeft / mockupWidth * 100);
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
var itemPaddingRightPct = "".concat(itemPaddingRight / mockupWidth * 100);
|
|
25
|
-
exports.itemPaddingRightPct = itemPaddingRightPct;
|
|
25
|
+
// Each item has the padding-right:26px in mockup.
|
|
26
|
+
var itemPaddingRightPct = exports.itemPaddingRightPct = "".concat(itemPaddingRight / mockupWidth * 100);
|
|
@@ -9,11 +9,10 @@ var infographic = 'interactive';
|
|
|
9
9
|
var review = 'review';
|
|
10
10
|
var normal = 'article';
|
|
11
11
|
var longform = 'longform';
|
|
12
|
-
var _default = {
|
|
12
|
+
var _default = exports["default"] = {
|
|
13
13
|
photography: photography,
|
|
14
14
|
infographic: infographic,
|
|
15
15
|
review: review,
|
|
16
16
|
normal: normal,
|
|
17
17
|
longform: longform
|
|
18
|
-
};
|
|
19
|
-
exports["default"] = _default;
|
|
18
|
+
};
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _categorySet = require("@twreporter/core/lib/constants/category-set");
|
|
9
|
-
|
|
10
8
|
var entities = 'entities';
|
|
11
9
|
var indexPage = 'index_page';
|
|
12
10
|
var latest = 'latest';
|
|
@@ -25,16 +23,18 @@ var user = 'user';
|
|
|
25
23
|
var analytics = 'analytics';
|
|
26
24
|
var footprints = 'footprints';
|
|
27
25
|
var donationHistory = 'donationHistory';
|
|
28
|
-
var postReviews = 'postReviews';
|
|
26
|
+
var postReviews = 'postReviews';
|
|
29
27
|
|
|
28
|
+
// sections in index_page
|
|
30
29
|
var editorPicksSection = 'editor_picks_section';
|
|
31
30
|
var infographicsSection = 'infographics_section';
|
|
32
31
|
var latestSection = 'latest_section';
|
|
33
32
|
var latestTopicSection = 'latest_topic_section';
|
|
34
33
|
var photosSection = 'photos_section';
|
|
35
34
|
var reviewsSection = 'reviews_section';
|
|
36
|
-
var topicsSection = 'topics_section';
|
|
35
|
+
var topicsSection = 'topics_section';
|
|
37
36
|
|
|
37
|
+
// categories in index_page
|
|
38
38
|
var categories = {
|
|
39
39
|
world: _categorySet.CATEGORY_PATH.world,
|
|
40
40
|
humanrights: _categorySet.CATEGORY_PATH.humanrights,
|
|
@@ -44,20 +44,23 @@ var categories = {
|
|
|
44
44
|
econ: _categorySet.CATEGORY_PATH.econ,
|
|
45
45
|
culture: _categorySet.CATEGORY_PATH.culture,
|
|
46
46
|
education: _categorySet.CATEGORY_PATH.education
|
|
47
|
-
};
|
|
47
|
+
};
|
|
48
48
|
|
|
49
|
+
// time stamp for next popup
|
|
49
50
|
var nextNotifyPopupTS = 'nextNotifyPopupTS';
|
|
51
|
+
|
|
50
52
|
/**
|
|
51
53
|
* fields in the `entities` field
|
|
52
54
|
*/
|
|
53
|
-
|
|
54
55
|
var postsInEntities = 'posts';
|
|
55
|
-
var topicsInEntities = 'topics';
|
|
56
|
+
var topicsInEntities = 'topics';
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
// origins
|
|
59
|
+
var origins = 'origins';
|
|
58
60
|
|
|
61
|
+
// settings
|
|
59
62
|
var settings = 'settings';
|
|
60
|
-
var _default = {
|
|
63
|
+
var _default = exports["default"] = {
|
|
61
64
|
categories: categories,
|
|
62
65
|
sections: {
|
|
63
66
|
editorPicksSection: editorPicksSection,
|
|
@@ -95,5 +98,4 @@ var _default = {
|
|
|
95
98
|
footprints: footprints,
|
|
96
99
|
donationHistory: donationHistory,
|
|
97
100
|
postReviews: postReviews
|
|
98
|
-
};
|
|
99
|
-
exports["default"] = _default;
|
|
101
|
+
};
|
|
@@ -4,12 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
9
|
var ReduxStoreContext = /*#__PURE__*/_react["default"].createContext(null);
|
|
13
|
-
|
|
14
|
-
var _default = ReduxStoreContext;
|
|
15
|
-
exports["default"] = _default;
|
|
10
|
+
var _default = exports["default"] = ReduxStoreContext;
|
package/lib/index.js
CHANGED
|
@@ -4,50 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _denormalizeAsset = require("./utils/denormalize-asset");
|
|
9
|
-
|
|
10
8
|
var _url = require("./utils/url");
|
|
11
|
-
|
|
12
9
|
var _actionTypes = _interopRequireDefault(require("./constants/action-types"));
|
|
13
|
-
|
|
14
10
|
var _createStore = _interopRequireDefault(require("./store/create-store"));
|
|
15
|
-
|
|
16
11
|
var _pagination = _interopRequireDefault(require("./utils/pagination"));
|
|
17
|
-
|
|
18
12
|
var _reduxStateFieldNames = _interopRequireDefault(require("./constants/redux-state-field-names"));
|
|
19
|
-
|
|
20
13
|
var _latest = require("./constants/latest");
|
|
21
|
-
|
|
22
14
|
var _reduxStore = _interopRequireDefault(require("./context/redux-store"));
|
|
23
|
-
|
|
24
15
|
var _provider = _interopRequireDefault(require("./component/provider"));
|
|
25
|
-
|
|
26
16
|
var _actions = _interopRequireDefault(require("./actions"));
|
|
27
|
-
|
|
28
17
|
var _auth = _interopRequireDefault(require("./reducers/auth"));
|
|
29
|
-
|
|
30
18
|
var _entities = _interopRequireDefault(require("./reducers/entities"));
|
|
31
|
-
|
|
32
19
|
var _featureTopic = _interopRequireDefault(require("./reducers/feature-topic"));
|
|
33
|
-
|
|
34
20
|
var _indexPage = _interopRequireDefault(require("./reducers/index-page"));
|
|
35
|
-
|
|
36
21
|
var _origins = _interopRequireDefault(require("./reducers/origins"));
|
|
37
|
-
|
|
38
22
|
var _relatedPostsOf = _interopRequireDefault(require("./reducers/related-posts-of"));
|
|
39
|
-
|
|
40
23
|
var _posts = require("./reducers/posts");
|
|
41
|
-
|
|
42
24
|
var _topics = require("./reducers/topics");
|
|
43
|
-
|
|
44
25
|
var _user = _interopRequireDefault(require("./reducers/user"));
|
|
45
|
-
|
|
46
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
47
|
-
|
|
48
27
|
// actions
|
|
49
28
|
// reducers
|
|
50
|
-
var _default = {
|
|
29
|
+
var _default = exports["default"] = {
|
|
51
30
|
actions: _actions["default"],
|
|
52
31
|
actionTypes: _actionTypes["default"],
|
|
53
32
|
createStore: _createStore["default"],
|
|
@@ -74,5 +53,4 @@ var _default = {
|
|
|
74
53
|
pagination: _pagination["default"]
|
|
75
54
|
},
|
|
76
55
|
LATEST_LIST_ID: _latest.LATEST_LIST_ID
|
|
77
|
-
};
|
|
78
|
-
exports["default"] = _default;
|
|
56
|
+
};
|
|
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = analytics;
|
|
7
|
-
|
|
8
7
|
var _actionTypes = _interopRequireDefault(require("../constants/action-types"));
|
|
9
|
-
|
|
10
8
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
11
|
-
|
|
12
9
|
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
|
-
function ownKeys(
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
11
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
16
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // lodash
|
|
22
17
|
var _ = {
|
|
23
18
|
get: _get["default"],
|
|
24
19
|
merge: _merge["default"]
|
|
@@ -32,12 +27,10 @@ var initState = {
|
|
|
32
27
|
readPostsCount: false,
|
|
33
28
|
readPostsSec: 0
|
|
34
29
|
};
|
|
35
|
-
|
|
36
30
|
function analytics() {
|
|
37
31
|
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initState;
|
|
38
32
|
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
39
33
|
var payload = action.payload;
|
|
40
|
-
|
|
41
34
|
switch (action.type) {
|
|
42
35
|
case _actionTypes["default"].analytics.update.request:
|
|
43
36
|
{
|
|
@@ -46,17 +39,12 @@ function analytics() {
|
|
|
46
39
|
isReady: false
|
|
47
40
|
});
|
|
48
41
|
}
|
|
49
|
-
|
|
50
42
|
case _actionTypes["default"].analytics.update.success:
|
|
51
43
|
{
|
|
52
44
|
var userID = _.get(payload, 'data.user_id');
|
|
53
|
-
|
|
54
45
|
var postID = _.get(payload, 'data.post_id');
|
|
55
|
-
|
|
56
46
|
var readPostsCount = _.get(payload, 'data.read_posts_count');
|
|
57
|
-
|
|
58
47
|
var readPostsSec = _.get(payload, 'data.read_posts_sec');
|
|
59
|
-
|
|
60
48
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
61
49
|
error: null,
|
|
62
50
|
isFetching: false,
|
|
@@ -67,7 +55,6 @@ function analytics() {
|
|
|
67
55
|
readPostsSec: readPostsSec
|
|
68
56
|
});
|
|
69
57
|
}
|
|
70
|
-
|
|
71
58
|
case _actionTypes["default"].analytics.update.failure:
|
|
72
59
|
{
|
|
73
60
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
@@ -76,7 +63,6 @@ function analytics() {
|
|
|
76
63
|
isReady: false
|
|
77
64
|
});
|
|
78
65
|
}
|
|
79
|
-
|
|
80
66
|
default:
|
|
81
67
|
return state;
|
|
82
68
|
}
|