Skip to content

Commit f2f6bd4

Browse files
committed
Make sure that the error/value fields are cleared when necessary
1 parent b2389e6 commit f2f6bd4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

database/helpers/useListReducer.ts

+9
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const listReducer = (
6363
}
6464
return {
6565
...state,
66+
error: undefined,
6667
value: addChild(state.value, action.snapshot, action.previousKey),
6768
};
6869
case 'change':
@@ -71,20 +72,26 @@ const listReducer = (
7172
}
7273
return {
7374
...state,
75+
error: undefined,
7476
value: changeChild(state.value, action.snapshot),
7577
};
7678
case 'error':
7779
return {
7880
...state,
7981
error: action.error,
8082
loading: false,
83+
value: {
84+
keys: undefined,
85+
values: undefined,
86+
},
8187
};
8288
case 'move':
8389
if (!action.snapshot) {
8490
return state;
8591
}
8692
return {
8793
...state,
94+
error: undefined,
8895
value: moveChild(state.value, action.snapshot, action.previousKey),
8996
};
9097
case 'remove':
@@ -93,13 +100,15 @@ const listReducer = (
93100
}
94101
return {
95102
...state,
103+
error: undefined,
96104
value: removeChild(state.value, action.snapshot),
97105
};
98106
case 'reset':
99107
return initialState;
100108
case 'value':
101109
return {
102110
...state,
111+
error: undefined,
103112
loading: false,
104113
};
105114
case 'empty':

0 commit comments

Comments
 (0)