@@ -61,9 +61,14 @@ define('composer/drafts', function () {
6161 var uid = save_id . split ( ':' ) [ 1 ] ;
6262 var storage = parseInt ( uid , 10 ) ? localStorage : sessionStorage ;
6363 var draft = {
64- title : storage . getItem ( save_id + ':title' ) ,
6564 text : storage . getItem ( save_id ) ,
6665 } ;
66+ [ 'cid' , 'title' , 'tags' ] . forEach ( function ( key ) {
67+ const value = storage . getItem ( save_id + ':' + key ) ;
68+ if ( value ) {
69+ draft [ key ] = value ;
70+ }
71+ } ) ;
6772 if ( ! parseInt ( uid , 10 ) ) {
6873 draft . handle = storage . getItem ( save_id + ':handle' ) ;
6974 }
@@ -78,13 +83,20 @@ define('composer/drafts', function () {
7883
7984 function saveDraft ( postContainer , draftIconEl , postData ) {
8085 if ( canSave ( app . user . uid ? 'localStorage' : 'sessionStorage' ) && postData && postData . save_id && postContainer . length ) {
81- var title = postContainer . find ( 'input.title' ) . val ( ) ;
86+ const titleEl = postContainer . find ( 'input.title' ) ;
87+ const title = titleEl && titleEl . val ( ) ;
8288 var raw = postContainer . find ( 'textarea' ) . val ( ) ;
8389 var storage = app . user . uid ? localStorage : sessionStorage ;
8490
85- if ( raw . length ) {
91+ if ( raw . length || ( title && title . length ) ) {
8692 storage . setItem ( postData . save_id , raw ) ;
87- storage . setItem ( postData . save_id + ':title' , title ) ;
93+
94+ if ( postData . hasOwnProperty ( 'cid' ) ) {
95+ // New topic only
96+ const tags = postContainer . find ( 'input.tags' ) . val ( ) ;
97+ storage . setItem ( postData . save_id + ':tags' , tags ) ;
98+ storage . setItem ( postData . save_id + ':title' , title ) ;
99+ }
88100 if ( ! app . user . uid ) {
89101 var handle = postContainer . find ( 'input.handle' ) . val ( ) ;
90102 storage . setItem ( postData . save_id + ':handle' , handle ) ;
0 commit comments