@@ -114,7 +114,6 @@ export type Pod = {
114114 midports ?: { } ;
115115 isSyncing : boolean ;
116116 io : { } ;
117- index : number ;
118117 x : number ;
119118 y : number ;
120119 width : number ;
@@ -164,7 +163,7 @@ export interface RepoSlice {
164163 setPodContent : ( { id, content } : { id : string ; content : string } ) => void ;
165164 addPod : (
166165 client : ApolloClient < object > | null ,
167- { parent, index , anchor, shift, id, type, lang, x, y, width, height } : any
166+ { parent, anchor, shift, id, type, lang, x, y, width, height } : any
168167 ) => void ;
169168 deletePod : (
170169 client : ApolloClient < object > | null ,
@@ -247,14 +246,8 @@ const createRepoSlice: StateCreator<
247246 setCurrentEditor : ( id ) => set ( { currentEditor : id } ) ,
248247 addPod : async (
249248 client ,
250- { parent, index , anchor, shift, id, type, lang, x, y, width, height }
249+ { parent, anchor, shift, id, type, lang, x, y, width, height }
251250 ) => {
252- if ( index === undefined ) {
253- index = get ( ) . pods [ parent ] . children . findIndex ( ( { id } ) => id === anchor ) ;
254- if ( index === - 1 ) throw new Error ( "Cannot find anchoar pod:" , anchor ) ;
255- index += shift | 0 ;
256- }
257-
258251 if ( ! parent ) {
259252 parent = "ROOT" ;
260253 }
@@ -289,7 +282,6 @@ const createRepoSlice: StateCreator<
289282 focus : false ,
290283 // from payload
291284 parent,
292- index,
293285 id,
294286 type,
295287 x,
@@ -306,7 +298,7 @@ const createRepoSlice: StateCreator<
306298 // TODO the children no longer need to be ordered
307299 // TODO the frontend should handle differently for the children
308300 // state.pods[parent].children.splice(index, 0, id);
309- state . pods [ parent ] . children . splice ( index , 0 , { id, type : pod . type } ) ;
301+ state . pods [ parent ] . children . push ( { id, type : pod . type } ) ;
310302 // DEBUG sort-in-place
311303 // TODO I can probably insert
312304 // CAUTION the sort expects -1,0,1, not true/false
@@ -319,7 +311,6 @@ const createRepoSlice: StateCreator<
319311 await doRemoteAddPod ( client , {
320312 repoId : get ( ) . repoId ,
321313 parent,
322- index,
323314 pod,
324315 } ) ;
325316 }
@@ -467,8 +458,10 @@ const createRepoSlice: StateCreator<
467458 set (
468459 produce ( ( state ) => {
469460 let pod = state . pods [ id ] ;
470- pod . name = name ;
471- pod . dirty = true ;
461+ if ( pod ) {
462+ pod . name = name ;
463+ pod . dirty = true ;
464+ }
472465 } ) ,
473466 false ,
474467 // @ts -ignore
@@ -707,13 +700,8 @@ const createRepoSlice: StateCreator<
707700 ) ;
708701 } ,
709702 loadRepo : async ( client , id ) => {
710- const {
711- pods,
712- name,
713- error,
714- userId,
715- collaboratorIds,
716- } = await doRemoteLoadRepo ( { id, client } ) ;
703+ const { pods, name, error, userId, collaboratorIds } =
704+ await doRemoteLoadRepo ( { id, client } ) ;
717705 set (
718706 produce ( ( state ) => {
719707 // TODO the children ordered by index
0 commit comments