Special case handling for selected namespace that no longer exists.
@@ -20,9 +20,13 @@ export default (
case FETCH_NAMESPACES_SUCCESS:
return {
result: payload.namespaces,
- selectedNamespace: window.localStorage.getItem('selectedNamespace')
+ selectedNamespace:
+ window.localStorage.getItem('selectedNamespace') &&
+ action.payload.namespaces.find(
+ ns => ns.name === window.localStorage.getItem('selectedNamespace')
+ )
? window.localStorage.getItem('selectedNamespace')
- : payload.namespaces[0]
+ : payload.namespaces.length > 0
? payload.namespaces[0].name
: null
}
