Skip to content

Commit 4137f7a

Browse files
committed
issue 1355 fixed: Error displayed when user quickly deletes items from the list
1 parent 23c314b commit 4137f7a

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

__tests__/__snapshots__/index.js.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ Object {
137137
"addUserTrait": [Function],
138138
"deleteUserTrait": [Function],
139139
"getAllUserTraits": [Function],
140+
"modifyUserTraitInit": [Function],
140141
"updateUserTrait": [Function],
141142
},
142143
"smp": Object {
@@ -197,14 +198,17 @@ Object {
197198
"countReset": [Function],
198199
"debug": [Function],
199200
"dir": [Function],
201+
"dirxml": [Function],
200202
"error": [Function],
201203
"group": [Function],
202204
"groupCollapsed": [Function],
203205
"groupEnd": [Function],
204206
"info": [Function],
205207
"log": [Function],
208+
"table": [Function],
206209
"time": [Function],
207210
"timeEnd": [Function],
211+
"timeLog": [Function],
208212
"trace": [Function],
209213
"warn": [Function],
210214
},

src/actions/settings.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import { createActions } from 'redux-actions';
7+
import _ from 'lodash';
78
import { getService } from '../services/user-traits';
89

910
/**
@@ -66,5 +67,6 @@ export default createActions({
6667
ADD_USER_TRAIT: addUserTrait,
6768
DELETE_USER_TRAIT: deleteUserTrait,
6869
UPDATE_USER_TRAIT: updateUserTrait,
70+
MODIFY_USER_TRAIT_INIT: _.noop,
6971
},
7072
});

src/reducers/settings.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ function onGetAllUserTraits(state, { error, payload }) {
2929
};
3030
}
3131

32+
/**
33+
* Handles SETTINGS/MODIFY_USER_TRAIT_INIT action.
34+
* @param {Object} state *
35+
* @return {Object} New state.
36+
*/
37+
function onModifyUserTraitInit(state) {
38+
return {
39+
...state,
40+
traitRequestCount: state.traitRequestCount + 1,
41+
};
42+
}
43+
3244
/**
3345
* Handles SETTINGS/ADD_USER_TRAIT action.
3446
* @param {Object} state
@@ -39,12 +51,16 @@ function onAddUserTrait(state, { error, payload }) {
3951
if (error) {
4052
logger.error('Failed to add user trait', payload);
4153
fireErrorMessage('Failed to add user trait', '');
42-
return state;
54+
return {
55+
...state,
56+
traitRequestCount: state.traitRequestCount - 1,
57+
};
4358
}
4459
const newData = payload.result[0];
4560
return {
4661
...state,
4762
userTraits: [...state.userTraits, newData],
63+
traitRequestCount: state.traitRequestCount - 1,
4864
};
4965
}
5066

@@ -58,7 +74,10 @@ function onUpdateUserTrait(state, { error, payload }) {
5874
if (error) {
5975
logger.error('Failed to update user trait', payload);
6076
fireErrorMessage('Failed to update user trait', '');
61-
return state;
77+
return {
78+
...state,
79+
traitRequestCount: state.traitRequestCount - 1,
80+
};
6281
}
6382
const newData = payload.result[0];
6483
const newUserTraits = state.userTraits.filter(trait => trait.traitId !== payload.traitId);
@@ -67,6 +86,7 @@ function onUpdateUserTrait(state, { error, payload }) {
6786
return {
6887
...state,
6988
userTraits: newUserTraits,
89+
traitRequestCount: state.traitRequestCount - 1,
7090
};
7191
}
7292

@@ -80,12 +100,16 @@ function onDeleteUserTrait(state, { error, payload }) {
80100
if (error) {
81101
logger.error('Failed to delete user trait', payload);
82102
fireErrorMessage('Failed to delete user trait', '');
83-
return state;
103+
return {
104+
...state,
105+
traitRequestCount: state.traitRequestCount - 1,
106+
};
84107
}
85108
const newUserTraits = state.userTraits.filter(trait => trait.traitId !== payload.traitId);
86109
return {
87110
...state,
88111
userTraits: newUserTraits,
112+
traitRequestCount: state.traitRequestCount - 1,
89113
};
90114
}
91115

@@ -96,11 +120,13 @@ function onDeleteUserTrait(state, { error, payload }) {
96120
* @return {Function} userTraits reducer.
97121
*/
98122
function create(initialState = {
123+
traitRequestCount: 0,
99124
userTraits: [],
100125
}) {
101126
const a = actions.settings;
102127
return handleActions({
103128
[a.getAllUserTraits]: onGetAllUserTraits,
129+
[a.modifyUserTraitInit]: onModifyUserTraitInit,
104130
[a.addUserTrait]: onAddUserTrait,
105131
[a.deleteUserTrait]: onDeleteUserTrait,
106132
[a.updateUserTrait]: onUpdateUserTrait,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy