mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
1) Changing the state of the react directly is not recommended, so avoid changing it directly.
2) Fixed API test cases.
This commit is contained in:
committed by
Akshay Joshi
parent
535739c0c7
commit
796a8a013a
@@ -80,15 +80,20 @@ export function statsReducer(state, action) {
|
||||
action.counterData = action.incoming;
|
||||
}
|
||||
|
||||
let newState = {};
|
||||
Object.keys(action.incoming).forEach(label => {
|
||||
let newEle = action.counter ? action.incoming[label] - action.counterData[label] : action.incoming[label];
|
||||
state[label] = state[label] || [];
|
||||
if(state[label].length >= X_AXIS_LENGTH) {
|
||||
state[label].pop();
|
||||
if(state[label]) {
|
||||
newState[label] = [
|
||||
action.counter ? action.incoming[label] - action.counterData[label] : action.incoming[label],
|
||||
...state[label].slice(0, X_AXIS_LENGTH-1),
|
||||
];
|
||||
} else {
|
||||
newState[label] = [
|
||||
action.counter ? action.incoming[label] - action.counterData[label] : action.incoming[label],
|
||||
];
|
||||
}
|
||||
state[label].unshift(newEle);
|
||||
});
|
||||
return state;
|
||||
return newState;
|
||||
}
|
||||
|
||||
const chartsDefault = {
|
||||
|
||||
Reference in New Issue
Block a user