File tree Expand file tree Collapse file tree 1 file changed +15
-14
lines changed
Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ Fliplet.FormBuilder.field('timer', {
8686 } ,
8787 start : function ( ) {
8888 if ( this . status === 'running' ) {
89- return ;
89+ this . stopInterval ( ) ;
9090 }
9191
9292 this . status = 'running' ;
@@ -195,28 +195,29 @@ Fliplet.FormBuilder.field('timer', {
195195 }
196196 } ,
197197 mounted : async function ( ) {
198- var $vm = this ;
199-
200198 this . value = 0 ;
199+ this . status = 'stopped' ;
200+
201+ this . stopInterval ( ) ;
201202
202203 if ( this . defaultValueSource !== 'default' ) {
203- this . setValueFromDefaultSettings ( { source : this . defaultValueSource , key : this . defaultValueKey } ) ;
204+ await this . setValueFromDefaultSettings ( { source : this . defaultValueSource , key : this . defaultValueKey } ) ;
204205 }
205206
206- Fliplet . App . Storage . get ( this . name ) . then ( function ( value ) {
207- if ( value ) {
208- $vm . startTimestamp = value ;
209- $vm . status = 'running' ;
210- $vm . setInterval ( ) ;
211- }
212- } ) ;
213-
214- this . stringValue = this . formatSeconds ( this . initialTimerValue ) ;
207+ const progressValue = await Fliplet . App . Storage . get ( this . name ) ;
215208
216- if ( this . autostart ) {
209+ if ( progressValue ) {
210+ this . startTimestamp = progressValue ;
211+ this . status = 'running' ;
212+ this . setInterval ( ) ;
213+ } else if ( this . autostart && ! this . timerInterval ) {
214+ this . startTimestamp = moment ( ) . valueOf ( ) / 1000 ;
215+ this . status = 'running' ;
217216 this . start ( ) ;
218217 }
219218
219+ this . stringValue = this . formatSeconds ( this . initialTimerValue ) ;
220+
220221 this . $emit ( '_input' , this . name , this . value ) ;
221222 this . $v . $reset ( ) ;
222223 } ,
You can’t perform that action at this time.
0 commit comments