@shopgate/pwa-common 7.9.4 → 7.9.5
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 +3 -3
- package/subscriptions/user.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-common",
|
|
3
|
-
"version": "7.9.
|
|
3
|
+
"version": "7.9.5",
|
|
4
4
|
"description": "Common library for the Shopgate Connect PWA.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@sentry/browser": "6.0.1",
|
|
19
|
-
"@shopgate/pwa-benchmark": "7.9.
|
|
19
|
+
"@shopgate/pwa-benchmark": "7.9.5",
|
|
20
20
|
"@virtuous/conductor": "~2.5.0",
|
|
21
21
|
"@virtuous/react-conductor": "~2.5.0",
|
|
22
22
|
"@virtuous/redux-persister": "1.1.0-beta.7",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"url-search-params": "^0.10.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@shopgate/pwa-core": "7.9.
|
|
47
|
+
"@shopgate/pwa-core": "7.9.5",
|
|
48
48
|
"lodash": "^4.17.4",
|
|
49
49
|
"prop-types": "~15.7.2",
|
|
50
50
|
"react": "~16.12.0",
|
package/subscriptions/user.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{getCurrentRoute}from'@shopgate/pwa-common/selectors/router';import event from'@shopgate/pwa-core/classes/Event';import registerEvents from'@shopgate/pwa-core/commands/registerEvents';import{LoadingProvider}from"../providers";import{fetchUser}from"../actions/user";import{successLogin}from"../action-creators";import{historyPush}from"../actions/router";import logout from"../actions/user/logout";import{appDidStart$,userWillLogin$,userLoginResponse$,userDidLogin$,userDidLogout$,userDidInitialize$,legacyConnectRegisterDidFail$,userSessionExpired$}from"../streams";import showModal from"../actions/modal/showModal";import{LOGIN_PATH}from"../constants/RoutePaths";import{LEGACY_URL_CONNECT_REGISTER}from"../constants/Registration";import{EVENT_USER_INITIALIZED}from"../constants/user";/**
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{getCurrentRoute}from'@shopgate/pwa-common/selectors/router';import event from'@shopgate/pwa-core/classes/Event';import registerEvents from'@shopgate/pwa-core/commands/registerEvents';import appConfig from"../helpers/config";import{LoadingProvider}from"../providers";import{fetchUser}from"../actions/user";import{successLogin}from"../action-creators";import{historyPush}from"../actions/router";import logout from"../actions/user/logout";import{appDidStart$,userWillLogin$,userLoginResponse$,userDidLogin$,userDidLogout$,userDidInitialize$,legacyConnectRegisterDidFail$,userSessionExpired$}from"../streams";import showModal from"../actions/modal/showModal";import{LOGIN_PATH}from"../constants/RoutePaths";import{LEGACY_URL_CONNECT_REGISTER}from"../constants/Registration";import{EVENT_USER_INITIALIZED}from"../constants/user";/**
|
|
2
2
|
* User subscriptions.
|
|
3
3
|
* @param {Function} subscribe The subscribe function.
|
|
4
4
|
*/export default function user(subscribe){/**
|
|
5
5
|
* Gets triggered when ever the user data need to be updated.
|
|
6
|
-
*/var userNeedsUpdate$=appDidStart$.merge(userDidLogin$);subscribe(userDidInitialize$,function(_ref){var events=_ref.events;events.emit(EVENT_USER_INITIALIZED);});subscribe(userWillLogin$,function(){LoadingProvider.setLoading(LOGIN_PATH);});subscribe(userLoginResponse$,function(){LoadingProvider.unsetLoading(LOGIN_PATH);});subscribe(userNeedsUpdate$,function(_ref2){var dispatch=_ref2.dispatch;dispatch(fetchUser());});subscribe(userDidLogout$,/*#__PURE__*/function(){var _ref4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3){var dispatch,action,isAutoLogout,confirmed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:dispatch=_ref3.dispatch,action=_ref3.action;if(!(action.notify===false)){_context.next=3;break;}return _context.abrupt("return");case 3:isAutoLogout=action.autoLogout;_context.next=6;return dispatch(showModal(_extends({confirm:'modal.ok',dismiss:null,message:'login.logout_message',title:null},isAutoLogout?{message:'login.auto_logout_message',confirm:'modal.login',dismiss:'modal.close'}:null)));case
|
|
6
|
+
*/var userNeedsUpdate$=appDidStart$.merge(userDidLogin$);subscribe(userDidInitialize$,function(_ref){var events=_ref.events;events.emit(EVENT_USER_INITIALIZED);});subscribe(userWillLogin$,function(){LoadingProvider.setLoading(LOGIN_PATH);});subscribe(userLoginResponse$,function(){LoadingProvider.unsetLoading(LOGIN_PATH);});subscribe(userNeedsUpdate$,function(_ref2){var dispatch=_ref2.dispatch;dispatch(fetchUser());});subscribe(userDidLogout$,/*#__PURE__*/function(){var _ref4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3){var dispatch,action,isAutoLogout,confirmed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:dispatch=_ref3.dispatch,action=_ref3.action;if(!(action.notify===false)){_context.next=3;break;}return _context.abrupt("return");case 3:isAutoLogout=action.autoLogout;if(!(isAutoLogout&&(appConfig===null||appConfig===void 0?void 0:appConfig.disableAutoLogoutModal)===true)){_context.next=6;break;}return _context.abrupt("return");case 6:_context.next=8;return dispatch(showModal(_extends({confirm:'modal.ok',dismiss:null,message:'login.logout_message',title:null},isAutoLogout?{message:'login.auto_logout_message',confirm:'modal.login',dismiss:'modal.close'}:null)));case 8:confirmed=_context.sent;if(isAutoLogout&&confirmed){dispatch(historyPush({pathname:LOGIN_PATH}));}case 10:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref4.apply(this,arguments);};}());subscribe(appDidStart$,function(_ref5){var dispatch=_ref5.dispatch,getState=_ref5.getState;registerEvents(['userLoggedIn']);event.addCallback('userLoggedIn',function(){var _getCurrentRoute=getCurrentRoute(getState()),_getCurrentRoute$stat=_getCurrentRoute.state;_getCurrentRoute$stat=_getCurrentRoute$stat===void 0?{}:_getCurrentRoute$stat;var redirect=_getCurrentRoute$stat.redirect;dispatch(successLogin(redirect));});});subscribe(legacyConnectRegisterDidFail$,function(_ref6){var dispatch=_ref6.dispatch;dispatch(historyPush({pathname:LEGACY_URL_CONNECT_REGISTER}));});subscribe(userSessionExpired$,function(_ref7){var dispatch=_ref7.dispatch;dispatch(logout(undefined,true));});}
|