File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,6 @@ class PageEditor {
4040 frequency : 30000 ,
4141 last : 0 ,
4242 } ;
43- this . draftHasError = false ;
4443
4544 if ( this . pageId !== 0 && this . draftsEnabled ) {
4645 window . setTimeout ( ( ) => {
@@ -115,17 +114,19 @@ class PageEditor {
115114
116115 try {
117116 const resp = await window . $http . put ( `/ajax/page/${ this . pageId } /save-draft` , data ) ;
118- this . draftHasError = false ;
119117 if ( ! this . isNewDraft ) {
120118 this . toggleDiscardDraftVisibility ( true ) ;
121119 }
122120 this . draftNotifyChange ( `${ resp . data . message } ${ Dates . utcTimeStampToLocalTime ( resp . data . timestamp ) } ` ) ;
123121 this . autoSave . last = Date . now ( ) ;
124122 } catch ( err ) {
125- if ( ! this . draftHasError ) {
126- this . draftHasError = true ;
127- window . $events . emit ( 'error' , this . autosaveFailText ) ;
128- }
123+ // Save the editor content in LocalStorage as a last resort, just in case.
124+ try {
125+ const saveKey = `draft-save-fail-${ ( new Date ( ) ) . toISOString ( ) } ` ;
126+ window . localStorage . setItem ( saveKey , JSON . stringify ( data ) ) ;
127+ } catch ( err ) { }
128+
129+ window . $events . emit ( 'error' , this . autosaveFailText ) ;
129130 }
130131
131132 }
You can’t perform that action at this time.
0 commit comments