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": "tslint -c ./tslint.json '{src,test}/**/*.ts?(x)'",
|
||||||
"tslint:fix": "tslint --fix -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": "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": "",
|
"author": "",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -137,18 +137,25 @@ export const deleteKapacitor = (kapacitor: Kapacitor) => ({
|
||||||
export type RemoveAndLoadSources = (
|
export type RemoveAndLoadSources = (
|
||||||
source: Source
|
source: Source
|
||||||
) => (dispatch) => Promise<void>
|
) => (dispatch) => Promise<void>
|
||||||
|
|
||||||
// Async action creators
|
// Async action creators
|
||||||
export const removeAndLoadSources = (source: Source) => async (
|
export const removeAndLoadSources = (source: Source) => async (
|
||||||
dispatch
|
dispatch,
|
||||||
|
getState
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
|
const {sources = []} = getState()
|
||||||
|
const filteredSources = sources.filter(s => s.id !== source.id)
|
||||||
|
|
||||||
|
dispatch(loadSources(filteredSources))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
await deleteSource(source)
|
await deleteSource(source)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
dispatch(loadSources(sources))
|
||||||
// A 404 means that either a concurrent write occurred or the source
|
// A 404 means that either a concurrent write occurred or the source
|
||||||
// passed to this action creator doesn't exist (or is undefined)
|
// passed to this action creator doesn't exist (or is undefined)
|
||||||
if (err.status !== HTTP_NOT_FOUND) {
|
if (err.status !== HTTP_NOT_FOUND) {
|
||||||
// eslint-disable-line no-magic-numbers
|
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue