@@ -25,7 +25,6 @@ import {
2525 GET_ZEST_SCRIPT ,
2626 IS_FULL_EXTENSION ,
2727 RESET_ZEST_SCRIPT ,
28- SET_SAVE_SCRIPT_ENABLE ,
2928 STOP_RECORDING ,
3029 UPDATE_TITLE ,
3130 ZAP_START_RECORDING ,
@@ -90,14 +89,12 @@ function startedAnimation(): void {
9089
9190async function restoreState ( ) : Promise < void > {
9291 console . log ( 'Restore state' ) ;
93- await Browser . runtime . sendMessage ( { type : SET_SAVE_SCRIPT_ENABLE } ) ;
9492 optionsIcon . title = OPTIONS ;
9593 downloadIcon . title = DOWNLOAD ;
9694 Browser . storage . sync
9795 . get ( {
9896 zaprecordingactive : false ,
9997 zapscriptname : '' ,
100- zapenablesavescript : false ,
10198 } )
10299 . then ( ( items ) => {
103100 if ( items . zaprecordingactive ) {
@@ -111,11 +108,6 @@ async function restoreState(): Promise<void> {
111108 } else {
112109 done ?. classList . add ( 'invisible' ) ;
113110 }
114- if ( ! items . zapenablesavescript ) {
115- saveScriptButton . classList . add ( 'disabled' ) ;
116- } else {
117- saveScriptButton . classList . remove ( 'disabled' ) ;
118- }
119111 } ) ;
120112}
121113
@@ -149,7 +141,9 @@ function startRecording(): void {
149141}
150142
151143function toggleRecording ( e : Event ) : void {
144+ console . log ( 'ZAP toggleRecording' ) ;
152145 e . preventDefault ( ) ;
146+ saveScriptButton . classList . remove ( 'disabled' ) ;
153147 Browser . storage . sync . get ( { zaprecordingactive : false } ) . then ( ( items ) => {
154148 if ( items . zaprecordingactive ) {
155149 stopRecording ( ) ;
@@ -189,7 +183,14 @@ function openHelpPage(): void {
189183 closePopup ( ) ;
190184}
191185
192- function downloadZestScript ( zestScriptJSON : string , title : string ) : void {
186+ function downloadZestScript (
187+ zestScriptJSON : string ,
188+ title : string ,
189+ statementCount : number
190+ ) : void {
191+ if ( statementCount === 0 ) {
192+ return ;
193+ }
193194 if ( title === '' ) {
194195 scriptNameInput ?. focus ( ) ;
195196 return ;
@@ -211,11 +212,12 @@ async function handleSaveScript(): Promise<void> {
211212 zaprecordingactive : false ,
212213 } ) ;
213214 if ( storageItems . zaprecordingactive ) {
215+ sendMessageToContentScript ( ZAP_STOP_RECORDING ) ;
214216 await Browser . runtime . sendMessage ( { type : STOP_RECORDING } ) ;
215217 }
216218 Browser . runtime . sendMessage ( { type : GET_ZEST_SCRIPT } ) . then ( ( items ) => {
217219 const msg = items as ZestScriptMessage ;
218- downloadZestScript ( msg . script , msg . title ) ;
220+ downloadZestScript ( msg . script , msg . title , msg . statementCount ) ;
219221 } ) ;
220222}
221223
0 commit comments