sensor store bug T T
This commit is contained in:
@@ -5,23 +5,21 @@ import {
|
||||
sensorListContainerAdapter,
|
||||
} from './sensor-list.state';
|
||||
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
export function reducer(state = initialState, action: Actions): State {
|
||||
switch (action.type) {
|
||||
case ActionType.ReadAllByDomainID: {
|
||||
return {
|
||||
...state,
|
||||
error: null,
|
||||
pending: true,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.ReadAllByDomainIDSuccess: {
|
||||
return sensorListContainerAdapter.setAll(action.payload.content, {...state, page: action.payload});
|
||||
return sensorListContainerAdapter.setAll(action.payload.content, {...state, page: action.payload, pending: false});
|
||||
}
|
||||
|
||||
case ActionType.ReadAllByDomainIDFailure: {
|
||||
return sensorListContainerAdapter.setError(action.payload, state);
|
||||
return sensorListContainerAdapter.setError(action.payload, {...state, page: null, pending: false});
|
||||
}
|
||||
|
||||
case ActionType.Read: {
|
||||
@@ -32,11 +30,11 @@ export function reducer(state = initialState, action: Actions): State {
|
||||
}
|
||||
|
||||
case ActionType.ReadSuccess: {
|
||||
return sensorListContainerAdapter.setOne(action.payload, {...state, page: null});
|
||||
return sensorListContainerAdapter.setOne(action.payload, {...state, page: null, pending: false});
|
||||
}
|
||||
|
||||
case ActionType.ReadFailure: {
|
||||
return sensorListContainerAdapter.setError(action.payload, state);
|
||||
return sensorListContainerAdapter.setError(action.payload, {...state, pending: false});
|
||||
}
|
||||
|
||||
case ActionType.Modify: {
|
||||
|
||||
@@ -19,5 +19,8 @@ export function getSelectors(selector: Selector<any, State>) {
|
||||
return {
|
||||
...sensorListContainerAdapter.getSelectors(selector),
|
||||
selectPending: createSelector(selector, (state: State) => state.pending),
|
||||
selectPage: createSelector(selector, (state: State) => {
|
||||
return state.page;
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export interface State {
|
||||
}
|
||||
|
||||
export const REDUCERS = {
|
||||
sensor: SensorListContainerStore.reducer,
|
||||
sensor_list: SensorListContainerStore.reducer,
|
||||
};
|
||||
|
||||
export const EFFECTS = [
|
||||
@@ -22,12 +22,9 @@ export const EFFECTS = [
|
||||
|
||||
export const selectState = createFeatureSelector<State>(MODULE.name);
|
||||
|
||||
export const SensorEntitySelector = SensorListContainerStore.getSelectors(createSelector(
|
||||
export const SensorListContainerSelector = SensorListContainerStore.getSelectors(createSelector(
|
||||
selectState,
|
||||
(state: State) => state.sensor_list
|
||||
(state: State) => {
|
||||
return state.sensor_list;
|
||||
}
|
||||
));
|
||||
|
||||
export const SensorPageSelector = createSelector(
|
||||
selectState,
|
||||
(state: State) => state.sensor_list.page
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user