push notification fixed

This commit is contained in:
2019-11-04 16:36:20 +01:00
parent 5e7fabe1ce
commit 6612f91047
5 changed files with 86 additions and 86 deletions
+1 -1
View File
@@ -14,5 +14,5 @@ RUN apk add --no-cache bash
RUN apk add --no-cache yarn
CMD cd /home/app/nextjs && yarn cache dir && yarn cache clean && yarn build && pm2 startOrReload ecosystem.config.js --env production --no-daemon
CMD cd /home/app/nextjs && yarn cache dir && yarn cache clean && yarn install && yarn build && pm2 startOrReload ecosystem.config.js --env production --no-daemon
+13 -15
View File
@@ -44,12 +44,12 @@ class WebPush extends Component {
}
UNSAFE_componentWillReceiveProps(nextProps) {
console.log("isUserSubscribedToPush ::: " + nextProps.isUserSubscribedToPush);
if (this.props.subscriveUserEnabled != nextProps.subscriveUserEnabled && nextProps.subscriveUserEnabled) {
this.onSubscribeUser()
}
if(!!nextProps.isUserSubscribedToPush){
this.setState({on: true})
if (!!nextProps.isUserSubscribedToPush) {
this.setState({ on: true })
}
}
@@ -80,7 +80,7 @@ class WebPush extends Component {
}
}
onSubscribeUser = () => {
onSubscribeUser = () => {
if (swRegistration == null) {
return
}
@@ -110,9 +110,9 @@ onSubscribeUser = () => {
});
}
})
}
}
onUnSubscribeUser = () => {
onUnSubscribeUser = () => {
swRegistration.pushManager.getSubscription()
.then((subscription) => {
@@ -145,34 +145,32 @@ onUnSubscribeUser = () => {
console.error('Failed to unsubscribe the user.', err);
});
}
}
onRegisterServiceWorker = () => {
onRegisterServiceWorker = () => {
navigator.serviceWorker.register('/static/js/Edeclic-service-worker.js')
.then(function (swReg) {
console.info('Service Worker is registered', swReg);
swRegistration = swReg;
})
}
}
render() {
render() {
return (<WebPushContext.Provider
value={{ on: this.state.on, toggleSubscription: this.toggleSubscription }}
{...this.props}
/>)
}
}
}
WebPush.propTypes = {
}
function mapStateToProps(state) {
return {
isUserSubscribedToPush: state.isUserSubscribedToPush
};
isUserSubscribedToPush: state.user.isUserSubscribedToPush
};
}
export default connect(mapStateToProps, { subscribeUserToPushRequest })(WebPush);
+2 -2
View File
@@ -8,7 +8,7 @@
<lastmod>2019-09-17</lastmod>
</url>,<url>
<loc>https://app.talentstube.com/Confidentialite</loc>
<lastmod>2019-10-18</lastmod>
<lastmod>2019-11-04</lastmod>
</url>,<url>
<loc>https://app.talentstube.com/Entreprises</loc>
<lastmod>2019-09-17</lastmod>
@@ -20,7 +20,7 @@
<lastmod>2019-10-14</lastmod>
</url>,<url>
<loc>https://app.talentstube.com/MentionsLegales</loc>
<lastmod>2019-10-18</lastmod>
<lastmod>2019-11-04</lastmod>
</url>,<url>
<loc>https://app.talentstube.com/Offres</loc>
<lastmod>2019-10-16</lastmod>
+1
View File
@@ -69,6 +69,7 @@
"dev": "cross-env PORT=3000 node server.js",
"build": "next build && yarn postExport && yarn copysw && yarn copySiteMap",
"start": "cross-env PORT=8000 NODE_ENV=production node server.js",
"startPreprod": "cross-env PORT=8000 NODE_ENV=preproduction node server.js",
"pm2-prod": "yarn build && pm2 start --name 'next' -- start",
"bs": "yarn build && yarn start",
"test": "yarn cypress run",
+3 -2
View File
@@ -181,19 +181,20 @@ export function user(state = {
return {
...state,
loading: false,
pushSubscribed: true
isUserSubscribedToPush: true
}
case SUBSCRIBE_USER_TO_PUSH_FAILURE:
return {
...state,
loading: false,
pushSubscribed: false,
isUserSubscribedToPush: false,
errors: action.err,
}
case FETCH_USER_SUBSCRIPTION_TO_PUSH_REQUEST:
return {
...state,
loading: true,
isUserSubscribedToPush: false,
}
case FETCH_USER_SUBSCRIPTION_TO_PUSH_SUCCESS:
return {