redux-clerk2 2.0.12 → 2.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -147,11 +147,11 @@ var Fetch = exports.Fetch = function (_BaseAction) {
147
147
  }
148
148
 
149
149
  var parameters = _extends({
150
- page: params.page || 1,
151
- query: params.query || undefined,
152
- order: params.order || undefined,
150
+ page: params && params.page || 1,
151
+ query: params && params.query || undefined,
152
+ order: params && params.order || undefined,
153
153
  sort: sort_order || undefined,
154
- limit: params.limit || 10
154
+ limit: params && params.limit || 10
155
155
  }, additionalData.filters);
156
156
  apiparams = _pickBy(parameters, _identity);
157
157
 
@@ -86,7 +86,13 @@ var success = exports.success = function success(state, action) {
86
86
  map.set('raw', state.get('raw').merge(newRecord));
87
87
 
88
88
  // Add new record to instance array using permanent uid
89
- map.setIn(['instances', action.instance, 'data'], map.getIn(['instances', action.instance, 'data']).push(uid));
89
+ var instanceData = map.getIn(['instances', action.instance, 'data'], (0, _immutable.List)());
90
+ // Check if key already present in instance
91
+ if (!(instanceData.indexOf(uid) !== -1)) {
92
+ map.setIn(['instances', action.instance, 'data'], instanceData.push(uid));
93
+ }
94
+ // OLD method
95
+ //map.setIn(['instances', action.instance, 'data'], map.getIn(['instances', action.instance, 'data']).push(uid));
90
96
 
91
97
  // UPDATE TOTAL COUNT FOR THIS INSTANCE
92
98
  map.setIn(['instances', action.instance, 'additionalData', 'total'], map.getIn(['instances', action.instance, 'additionalData', 'total']) + 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redux-clerk2",
3
- "version": "2.0.12",
3
+ "version": "2.0.14",
4
4
  "description": "Redux Clerk handles the async CRUD in your Redux App.",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -124,11 +124,11 @@ export class Fetch extends BaseAction {
124
124
  }
125
125
 
126
126
  const parameters = {
127
- page: params.page || 1
128
- ,query: params.query || undefined
129
- ,order: params.order || undefined
127
+ page: params && params.page || 1
128
+ ,query: params && params.query || undefined
129
+ ,order: params && params.order || undefined
130
130
  ,sort: sort_order || undefined
131
- ,limit: params.limit || 10
131
+ ,limit: params && params.limit || 10
132
132
  ,...additionalData.filters
133
133
  }
134
134
  apiparams = _pickBy(parameters, _identity);
@@ -73,7 +73,13 @@ export const start = (state, action) => {
73
73
  map.set('raw', state.get('raw').merge(newRecord))
74
74
 
75
75
  // Add new record to instance array using permanent uid
76
- map.setIn(['instances', action.instance, 'data'], map.getIn(['instances', action.instance, 'data']).push(uid));
76
+ const instanceData = map.getIn(['instances', action.instance, 'data'], List());
77
+ // Check if key already present in instance
78
+ if(!instanceData.includes(uid)){
79
+ map.setIn(['instances', action.instance, 'data'], instanceData.push(uid));
80
+ }
81
+ // OLD method
82
+ //map.setIn(['instances', action.instance, 'data'], map.getIn(['instances', action.instance, 'data']).push(uid));
77
83
 
78
84
  // UPDATE TOTAL COUNT FOR THIS INSTANCE
79
85
  map.setIn(['instances', action.instance, 'additionalData', 'total'], map.getIn(['instances', action.instance, 'additionalData', 'total']) + 1 );
package/CHANGELOG.md DELETED
@@ -1,79 +0,0 @@
1
- ## 1.0.0
2
- ###### _August 10, 2017_
3
-
4
- - Convert responseData to Immutable data structure before adding to store ([#51](https://github.com/GetAmbassador/redux-clerk/pull/51))
5
-
6
- ## 1.0.0-rc.4
7
- ###### _May 2, 2017_
8
-
9
- - Accept responseData in handleSuccess for the update action ([#48](https://github.com/GetAmbassador/redux-clerk/pull/48))
10
- - Update docs to reflect optional optimism ([#47](https://github.com/GetAmbassador/redux-clerk/pull/47))
11
-
12
- ## 1.0.0-rc.3
13
- ###### _April 10, 2017_
14
-
15
- - Cast all raw ids to strings ([#44](https://github.com/GetAmbassador/redux-clerk/pull/44))
16
- - Update selectors to handle optional optimism ([#43](https://github.com/GetAmbassador/redux-clerk/pull/43))
17
- - Make optimistic updates optional ([#41](https://github.com/GetAmbassador/redux-clerk/pull/41))
18
-
19
- ## 1.0.0-rc.2
20
- ###### _March 23, 2017_
21
-
22
- - Added pre action hooks ([#38](https://github.com/GetAmbassador/redux-clerk/pull/38))
23
-
24
- ## 1.0.0-rc.1
25
- ###### _March 22, 2017_
26
-
27
- - Added post action hooks ([#36](https://github.com/GetAmbassador/redux-clerk/pull/36))
28
- - Rename delete action to remove to avoid reserved word conflicts ([#35](https://github.com/GetAmbassador/redux-clerk/pull/35))
29
-
30
- ## 0.3.0
31
- ###### _March 15, 2017_
32
-
33
- - Fetch response will now deep merge response data into raw data ([#33](https://github.com/GetAmbassador/redux-clerk/pull/33))
34
-
35
- ## 0.2.8
36
- ###### _February 21, 2017_
37
-
38
- - Cast uid to int in record selector ([#31](https://github.com/GetAmbassador/redux-clerk/pull/31))
39
-
40
- ## 0.2.7
41
- ###### _February 16, 2017_
42
-
43
- - Added the get selector ([#29](https://github.com/GetAmbassador/redux-clerk/pull/29))
44
-
45
- ## 0.2.6
46
- ###### _January 11, 2017_
47
-
48
- - Added the datasetProperty selector ([#27](https://github.com/GetAmbassador/redux-clerk/pull/27))
49
-
50
- ## 0.2.5
51
- ###### _January 3, 2017_
52
-
53
- - Return Map instead of List for empty dataset ([#25](https://github.com/GetAmbassador/redux-clerk/pull/25))
54
- - Ensure data is properly converted between actions and reducers ([#24](https://github.com/GetAmbassador/redux-clerk/pull/24))
55
-
56
- ## 0.2.4
57
- ###### _December 15, 2016_
58
-
59
- - uidField option has been removed for the reducer (it is not longer needed) ([#22](https://github.com/GetAmbassador/redux-clerk/pull/22))
60
-
61
- ## 0.2.3
62
- ###### _December 14, 2016_
63
-
64
- - Records are now added while updating if not already in state ([#20](https://github.com/GetAmbassador/redux-clerk/pull/20))
65
-
66
- ## 0.2.2
67
- ###### _December 13, 2016_
68
-
69
- - Added the ability to return fetch response as an object or array ([#18](https://github.com/GetAmbassador/redux-clerk/pull/18))
70
-
71
- ## 0.2.1
72
- ###### _December 7, 2016_
73
-
74
- - Added the ability to pass additional data with fetch, create and delete actions ([#16](https://github.com/GetAmbassador/redux-clerk/pull/16))
75
-
76
- ## 0.2.0
77
- ###### _December 5, 2016_
78
-
79
- - Initial Release