[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,5 @@
import api from 'flavours/glitch/util/api';
import { CancelToken } from 'axios';
import { CancelToken, isCancel } from 'axios';
import { throttle } from 'lodash';
import { search as emojiSearch } from 'flavours/glitch/util/emoji/emoji_mart_search_light';
import { useEmoji } from './emojis';
@@ -8,6 +8,7 @@ import { recoverHashtags } from 'flavours/glitch/util/hashtag';
import resizeImage from 'flavours/glitch/util/resize_image';
import { updateTimeline } from './timelines';
import { showAlertForError } from './alerts';
let cancelFetchComposeSuggestionsAccounts;
@@ -320,6 +321,10 @@ const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) =>
},
}).then(response => {
dispatch(readyComposeSuggestionsAccounts(token, response.data));
}).catch(error => {
if (!isCancel(error)) {
dispatch(showAlertForError(error));
}
});
}, 200, { leading: true, trailing: true });