File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,6 +99,13 @@ class GraphUndoRedo extends GraphComponent {
9999 ) ,
100100 } ) ;
101101 this . curActionIndex += 1 ;
102+
103+ if ( this . actionArr . length > 100 ) {
104+ const drop = this . actionArr . length - 100 ;
105+ this . actionArr . splice ( 0 , drop ) ;
106+ this . curActionIndex -= drop ;
107+ }
108+
102109 this . informUI ( ) ;
103110 }
104111
Original file line number Diff line number Diff line change @@ -48,11 +48,15 @@ class GraphLoadSave extends GraphUndoRedo {
4848 }
4949
5050 static stringifyAction ( { actionName, parameters } ) {
51- return { actionName, parameters : window . btoa ( JSON . stringify ( parameters ) ) } ;
51+ return { actionName, parameters : JSON . stringify ( parameters ) } ;
5252 }
5353
5454 static parseAction ( { actionName, parameters } ) {
55- return { actionName, parameters : JSON . parse ( window . atob ( parameters ) ) } ;
55+ try {
56+ return { actionName, parameters : JSON . parse ( parameters ) } ;
57+ } catch {
58+ return { actionName, parameters : JSON . parse ( window . atob ( parameters ) ) } ;
59+ }
5660 }
5761
5862 jsonifyGraph ( ) {
Original file line number Diff line number Diff line change @@ -12,8 +12,10 @@ const localStorageGet = (key) => {
1212const localStorageSet = ( key , value ) => {
1313 try {
1414 window . localStorage . setItem ( key , value ) ;
15+ return true ;
1516 } catch ( e ) {
1617 toast . error ( e . message ) ;
18+ return false ;
1719 }
1820} ;
1921
@@ -53,12 +55,18 @@ const localStorageManager = {
5355 get ( id ) {
5456 const raw = localStorageGet ( id ) ;
5557 if ( raw === null ) return null ;
56- return JSON . parse ( window . atob ( raw ) ) ;
58+ try {
59+ return JSON . parse ( raw ) ;
60+ } catch {
61+ return JSON . parse ( window . atob ( raw ) ) ;
62+ }
5763 } ,
5864 save ( id , graphContent ) {
5965 this . addGraph ( id ) ;
60- const serializedJson = JSON . stringify ( graphContent ) ;
61- localStorageSet ( id , window . btoa ( serializedJson ) ) ;
66+ if ( ! localStorageSet ( id , JSON . stringify ( graphContent ) ) ) {
67+ const stripped = { ...graphContent , actionHistory : [ ] } ;
68+ localStorageSet ( id , JSON . stringify ( stripped ) ) ;
69+ }
6270 } ,
6371 remove ( id ) {
6472 if ( this . allgs . delete ( id ) ) this . saveAllgs ( ) ;
You can’t perform that action at this time.
0 commit comments