[Glitch] Add missing rejection handling for Promises

Port missing parts from 2c51bc0ca5 to glitch-soc
This commit is contained in:
Thibaut Girka
2019-02-10 21:28:29 +01:00
parent 6b2eefc7bf
commit a963ea67dd
8 changed files with 54 additions and 29 deletions

View File

@@ -1,5 +1,6 @@
import api from 'flavours/glitch/util/api';
import { debounce } from 'lodash';
import { showAlertForError } from './alerts';
export const SETTING_CHANGE = 'SETTING_CHANGE';
export const SETTING_SAVE = 'SETTING_SAVE';
@@ -23,7 +24,9 @@ const debouncedSave = debounce((dispatch, getState) => {
const data = getState().get('settings').filter((_, path) => path !== 'saved').toJS();
api(getState).put('/api/web/settings', { data }).then(() => dispatch({ type: SETTING_SAVE }));
api(getState).put('/api/web/settings', { data })
.then(() => dispatch({ type: SETTING_SAVE }))
.catch(error => dispatch(showAlertForError(error)));
}, 5000, { trailing: true });
export function saveSettings() {