@@ -229,7 +229,7 @@ export default class EditorPage extends React.Component<IEditorPageProps, IEdito
229229 </ div >
230230 < div className = "editor-page-right-sidebar" >
231231 < TagInput
232- tags = { this . props . project . tags }
232+ tags = { this . state . project ? this . state . project . tags : this . props . project . tags }
233233 lockedTags = { this . state . lockedTags }
234234 selectedRegions = { this . state . selectedRegions }
235235 onChange = { this . onTagsChanged }
@@ -309,44 +309,75 @@ export default class EditorPage extends React.Component<IEditorPageProps, IEdito
309309 }
310310
311311 private onTagRenamed = async ( tagName : string , newTagName : string ) : Promise < void > => {
312- const { project, selectedAsset } = this . state ;
313- const assetService = new AssetService ( project ) ;
314- const asset = await assetService . renameTag ( project . assets , tagName , newTagName , selectedAsset ) ;
315-
316- const newProject : IProject = {
317- ...project ,
318- tags : project . tags . map ( ( t ) => ( t . name === tagName ) ? { ...t , name : newTagName } : t ) ,
319- } ;
312+ const { project } = this . state ;
320313 this . setState ( {
321- project : newProject ,
322- selectedAsset : asset || selectedAsset ,
314+ project : {
315+ ...project ,
316+ tags : project . tags . map ( ( t ) => ( t . name === tagName ) ? { ...t , name : newTagName } : t ) ,
317+ }
323318 } , async ( ) => {
324- await this . props . actions . saveProject ( newProject ) ;
325- if ( asset ) {
326- this . canvas . current . updateCanvasToolsRegions ( asset ) ;
319+ await this . props . actions . saveProject ( project ) ;
320+ if ( this . canvas . current ) {
321+ this . canvas . current . updateCanvasToolsRegions ( ) ;
327322 }
328323 } ) ;
324+
325+ // const { project, selectedAsset } = this.state;
326+ // const assetService = new AssetService(project);
327+ // const asset = await assetService.renameTag(project.assets, tagName, newTagName, selectedAsset);
328+
329+ // const newProject: IProject = {
330+ // ...project,
331+ // tags: project.tags.map((t) => (t.name === tagName) ? {...t, name: newTagName} : t),
332+ // };
333+ // this.setState({
334+ // project: newProject,
335+ // selectedAsset: asset || selectedAsset,
336+ // }, async () => {
337+ // await this.props.actions.saveProject(newProject);
338+ // if (asset) {
339+ // this.canvas.current.updateCanvasToolsRegions(asset);
340+ // }
341+ // });
329342 }
330343
331344 private confirmTagDeleted = ( tagName : string ) : void => {
332345 this . deleteTagConfirm . current . open ( tagName ) ;
333346 }
334347
335348 private onTagDeleted = async ( tagName : string ) : Promise < void > => {
336- const { selectedAsset } = this . state ;
337- const { project } = this . props ;
338- const newProject : IProject = {
349+ const { project, selectedAsset } = this . state ;
350+ const newProject = {
339351 ...project ,
340352 tags : project . tags . filter ( ( t ) => t . name !== tagName ) ,
341- } ;
342- await this . props . actions . saveProject ( newProject ) ;
353+ }
343354
344- const assetService = new AssetService ( project ) ;
355+ const assetService = new AssetService ( newProject ) ;
345356 const asset = await assetService . deleteTag ( project . assets , tagName , selectedAsset ) ;
346- if ( asset ) {
347- this . canvas . current . updateCanvasToolsRegions ( asset ) ;
348- this . setState ( { selectedAsset : asset } ) ;
349- }
357+ this . setState ( {
358+ project : newProject ,
359+ selectedAsset : asset || selectedAsset ,
360+ } , async ( ) => {
361+ await this . props . actions . saveProject ( newProject ) ;
362+ if ( this . canvas . current ) {
363+ this . canvas . current . updateCanvasToolsRegions ( asset ) ;
364+ }
365+ } ) ;
366+
367+ // const { selectedAsset } = this.state;
368+ // const { project } = this.props;
369+ // const newProject: IProject = {
370+ // ...project,
371+ // tags: project.tags.filter((t) => t.name !== tagName),
372+ // };
373+ // await this.props.actions.saveProject(newProject);
374+
375+ // const assetService = new AssetService(project);
376+ // const asset = await assetService.deleteTag(project.assets, tagName, selectedAsset);
377+ // if (asset) {
378+ // this.canvas.current.updateCanvasToolsRegions(asset);
379+ // this.setState({selectedAsset: asset});
380+ // }
350381 }
351382
352383 private onCtrlTagClicked = ( tag : ITag ) : void => {
0 commit comments