return to default type when category changes

This commit is contained in:
svetlagasheva 2019-10-18 16:54:41 +03:00
parent 0de4bad6c6
commit 8255c7fd20

View file

@ -16,9 +16,6 @@ const useAddons = (category, type) => {
setAddons(state.ctx.content.addons);
};
core.on('NewModel', onNewState);
core.dispatch({
action: 'LoadCtx'
});
onNewState();
return () => {
core.off('NewModel', onNewState);
@ -29,7 +26,7 @@ const useAddons = (category, type) => {
const name = event.dataset.name;
if (name === 'category') {
const nextCategory = CATEGORIES.includes(value) ? value : '';
window.location.replace(`#/addons/${nextCategory}/${type}`);
window.location.replace(`#/addons/${nextCategory}/${DEFAULT_TYPE}`);
} else if (name === 'type') {
const nextType = typeof value === 'string' ? value : '';
window.location.replace(`#/addons/${category}/${nextType}`);