Open jonashartwig opened 8 years ago
export function deleteDashboard() {
return (dispatch, getState) => {
const store = getState(),
dashboardId = store.dashboards.active.model.id,
favorite = store.favorites.items.find(favorite => favorite.identifier === dashboardId);
if(favorite)
dispatch(
batchActions([
closeDashboard(),
showSystemMessage("dashboard.delete.success"),
removeFavorite(favorite)
])
);
else
dispatch(
batchActions([
closeDashboard(),
showSystemMessage("dashboard.delete.success")
])
);
};
}
export function closeDashboard() {
return batchActions([
removeActiveRecentVisit(),
navigateToDashboardHome(),
{
type: DASHBOARD_ACTIONS.CLOSE
}
]);
}
this is the example code that works. if i add a promise to it it somehow explodes because closeDashboard removes some store state that is required by some views. I cnat figure out how. This might not even be an issue of this api.
// for some reason not working
export function deleteDashboard() {
return (dispatch, getState) => {
const store = getState(),
dashboardId = store.dashboards.active.model.id,
favorite = store.favorites.items.find(favorite => favorite.identifier === dashboardId);
return Promise.resolve()
.then(() => {
if(favorite)
dispatch(
batchActions([
closeDashboard(),
showSystemMessage("dashboard.delete.success"),
removeFavorite(favorite)
])
);
else
dispatch(
batchActions([
closeDashboard(),
showSystemMessage("dashboard.delete.success")
])
);
});
};
}
if i remove the batched action from the promise it works:
export function deleteDashboard() {
return (dispatch, getState) =>
serviceDeleteDashboard(getState().dashboards.active.model.id)
.then(() => {
dispatch(removeActiveRecentVisit());
dispatch(navigateToDashboardHome());
dispatch({
type: DASHBOARD_ACTIONS.CLOSE
});
dispatch(showSystemMessage("dashboard.delete.success")
);
});
}
a bit more info: removeActiveRecentVisit(), DASHBOARD_ACTIONS.CLOSE, showSystemMessage are plain store mutations, navigateToDashboardHome however changes the url route using redux-router.
Hi,
is nesting batchActions supported? I am experiencing some issues which i cannot pinpoint right now.