Add missing rejection handling for Promises (#7008)
* Add eslint-plugin-promise to detect uncaught rejections * Move alert generation for errors to actions/alert * Add missing rejection handling for Promises * Use catch() instead of onReject on then() Then it will catches rejection from onFulfilled. This detection can be disabled by `allowThen` option, though.
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
import api from '../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() {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user