@@ -110,7 +110,10 @@ export default (params?: LocalStorageDataProviderParams): DataProvider => {
110110 . update < RecordType > ( resource , params )
111111 . then ( response => {
112112 updateLocalStorage ( ( ) => {
113- const resourceData = getResourceCollection ( data , resource ) ;
113+ const resourceData = getResourceCollection (
114+ data ,
115+ resource
116+ ) ;
114117 const index = resourceData . findIndex (
115118 record => record . id == params . id
116119 ) ;
@@ -139,27 +142,32 @@ export default (params?: LocalStorageDataProviderParams): DataProvider => {
139142 return Promise . reject ( error ) ;
140143 }
141144
142- return baseDataProvider . updateMany ( resource , params ) . then ( response => {
143- updateLocalStorage ( ( ) => {
144- const resourceData = getResourceCollection ( data , resource ) ;
145- params . ids . forEach ( id => {
146- const index = resourceData . findIndex (
147- record => record . id == id
145+ return baseDataProvider
146+ . updateMany ( resource , params )
147+ . then ( response => {
148+ updateLocalStorage ( ( ) => {
149+ const resourceData = getResourceCollection (
150+ data ,
151+ resource
148152 ) ;
153+ params . ids . forEach ( id => {
154+ const index = resourceData . findIndex (
155+ record => record . id == id
156+ ) ;
149157
150- if ( index === - 1 ) {
151- return ;
152- }
158+ if ( index === - 1 ) {
159+ return ;
160+ }
153161
154- resourceData . splice ( index , 1 , {
155- ...resourceData [ index ] ,
156- ...params . data ,
162+ resourceData . splice ( index , 1 , {
163+ ...resourceData [ index ] ,
164+ ...params . data ,
165+ } ) ;
157166 } ) ;
158167 } ) ;
159- } ) ;
160168
161- return response ;
162- } ) ;
169+ return response ;
170+ } ) ;
163171 } ,
164172 create : < RecordType extends Omit < RaRecord , 'id' > = any > (
165173 resource ,
@@ -193,7 +201,10 @@ export default (params?: LocalStorageDataProviderParams): DataProvider => {
193201 . delete < RecordType > ( resource , params )
194202 . then ( response => {
195203 updateLocalStorage ( ( ) => {
196- const resourceData = getResourceCollection ( data , resource ) ;
204+ const resourceData = getResourceCollection (
205+ data ,
206+ resource
207+ ) ;
197208 const index = resourceData . findIndex (
198209 record => record . id == params . id
199210 ) ;
@@ -219,20 +230,27 @@ export default (params?: LocalStorageDataProviderParams): DataProvider => {
219230 return Promise . reject ( error ) ;
220231 }
221232
222- return baseDataProvider . deleteMany ( resource , params ) . then ( response => {
223- updateLocalStorage ( ( ) => {
224- const resourceData = getResourceCollection ( data , resource ) ;
225- const indexes = params . ids
226- . map ( id =>
227- resourceData . findIndex ( record => record . id == id )
228- )
229- . filter ( index => index !== - 1 ) ;
233+ return baseDataProvider
234+ . deleteMany ( resource , params )
235+ . then ( response => {
236+ updateLocalStorage ( ( ) => {
237+ const resourceData = getResourceCollection (
238+ data ,
239+ resource
240+ ) ;
241+ const indexes = params . ids
242+ . map ( id =>
243+ resourceData . findIndex (
244+ record => record . id == id
245+ )
246+ )
247+ . filter ( index => index !== - 1 ) ;
230248
231- pullAt ( resourceData , indexes ) ;
232- } ) ;
249+ pullAt ( resourceData , indexes ) ;
250+ } ) ;
233251
234- return response ;
235- } ) ;
252+ return response ;
253+ } ) ;
236254 } ,
237255 } ;
238256} ;
0 commit comments