File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -182,15 +182,12 @@ export default class CachingAdapter implements Adapter, BulkImportResource<TItem
182182 if ( ! folder ) {
183183 throw new UnknownFolderOrderError ( )
184184 }
185+ let newChildren = [ ]
185186 order . forEach ( item => {
186187 const child = folder . findItem ( item . type , item . id )
187188 if ( ! child || String ( child . parentId ) !== String ( folder . id ) ) {
188189 throw new UnknownFolderItemOrderError ( id + ':' + JSON . stringify ( item ) )
189190 }
190- } )
191- let newChildren = [ ]
192- order . forEach ( item => {
193- const child = folder . findItem ( item . type , item . id )
194191 newChildren . push ( child )
195192 } )
196193 const diff = difference ( folder . children . map ( i => i . type + ':' + i . id ) , order . map ( i => i . type + ':' + i . id ) )
@@ -201,8 +198,9 @@ export default class CachingAdapter implements Adapter, BulkImportResource<TItem
201198 diff . forEach ( item => {
202199 const [ type , id ] = item . split ( ':' )
203200 const child = folder . findItem ( type , id )
201+ if ( ! child ) return
204202 const index = folder . children . indexOf ( child )
205- newChildren = newChildren . slice ( 0 , index - 1 ) . concat ( [ child ] , newChildren . slice ( index - 1 ) )
203+ newChildren = newChildren . slice ( 0 , index ) . concat ( [ child ] , newChildren . slice ( index ) )
206204 } )
207205 }
208206 folder . children = newChildren
You can’t perform that action at this time.
0 commit comments