0
0
Fork 0

Keep WebPush settings (#5879)

This commit is contained in:
abcang 2017-12-09 10:31:37 +09:00 committed by Eugen Rochko
parent ec3b449baa
commit 99242b92bc
4 changed files with 74 additions and 7 deletions

View file

@ -1,4 +1,5 @@
import axios from 'axios';
import { setSettingsToLocalStorage } from '../web_push_subscription';
export const SET_BROWSER_SUPPORT = 'PUSH_NOTIFICATIONS_SET_BROWSER_SUPPORT';
export const SET_SUBSCRIPTION = 'PUSH_NOTIFICATIONS_SET_SUBSCRIPTION';
@ -42,11 +43,15 @@ export function saveSettings() {
const state = getState().get('push_notifications');
const subscription = state.get('subscription');
const alerts = state.get('alerts');
const data = { alerts };
axios.put(`/api/web/push_subscriptions/${subscription.get('id')}`, {
data: {
alerts,
},
data,
}).then(() => {
const me = getState().getIn(['meta', 'me']);
if (me) {
setSettingsToLocalStorage(me, data);
}
});
};
}