Remove source immediately rather than wait for reload
parent
39d1fad53e
commit
7387eec15e
|
@ -22,7 +22,8 @@
|
|||
"tslint": "tslint -c ./tslint.json '{src,test}/**/*.ts?(x)'",
|
||||
"tslint:fix": "tslint --fix -c ./tslint.json '{src,test}/**/*.ts?(x)'",
|
||||
"tsc": "tsc -p ./tsconfig.json --noEmit --pretty",
|
||||
"tsc:watch": "tsc -p ./tsconfig.json --noEmit --pretty -w"
|
||||
"tsc:watch": "tsc -p ./tsconfig.json --noEmit --pretty -w",
|
||||
"dev": "yarn clean && yarn start"
|
||||
},
|
||||
"author": "",
|
||||
"devDependencies": {
|
||||
|
|
|
@ -137,18 +137,25 @@ export const deleteKapacitor = (kapacitor: Kapacitor) => ({
|
|||
export type RemoveAndLoadSources = (
|
||||
source: Source
|
||||
) => (dispatch) => Promise<void>
|
||||
|
||||
// Async action creators
|
||||
export const removeAndLoadSources = (source: Source) => async (
|
||||
dispatch
|
||||
dispatch,
|
||||
getState
|
||||
): Promise<void> => {
|
||||
const {sources = []} = getState()
|
||||
const filteredSources = sources.filter(s => s.id !== source.id)
|
||||
|
||||
dispatch(loadSources(filteredSources))
|
||||
|
||||
try {
|
||||
try {
|
||||
await deleteSource(source)
|
||||
} catch (err) {
|
||||
dispatch(loadSources(sources))
|
||||
// A 404 means that either a concurrent write occurred or the source
|
||||
// passed to this action creator doesn't exist (or is undefined)
|
||||
if (err.status !== HTTP_NOT_FOUND) {
|
||||
// eslint-disable-line no-magic-numbers
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue