@@ -410,11 +410,12 @@ var AnnotationSelector = Panel.extend({
410410 } ,
411411
412412 _saveAnnotation ( annotation ) {
413- if ( this . viewer !== null && this . viewer !== undefined && ! this . viewer . _saving ) {
413+ if ( this . viewer && ! this . viewer . _saving ) {
414414 this . viewer . _saving = { } ;
415415 }
416+ const vsaving = ( this . viewer || { } ) . _saving ;
416417 if ( ! annotation . _saving && ! annotation . _inFetch && ! annotation . get ( 'loading' ) ) {
417- this . viewer . _saving [ annotation . id ] = true ;
418+ vsaving [ annotation . id ] = true ;
418419 this . $el . addClass ( 'saving' ) ;
419420 const lastSaveAgain = annotation . _saveAgain ;
420421 annotation . _saving = true ;
@@ -429,28 +430,25 @@ var AnnotationSelector = Panel.extend({
429430 annotation . _saveAgain = Math . min ( lastSaveAgain ? lastSaveAgain * 2 : 5 , 300 ) ;
430431 } ) . always ( ( ) => {
431432 annotation . _saving = false ;
432- if ( this . viewer === null || this . viewer === undefined ) {
433- return ;
434- }
435- delete this . viewer . _saving [ annotation . id ] ;
433+ delete vsaving [ annotation . id ] ;
436434 if ( annotation . _saveAgain !== undefined && annotation . _saveAgain !== false ) {
437435 if ( annotation . _saveAgain === 'delete' ) {
438436 annotation . destroy ( ) ;
439437 } else if ( ! annotation . _saveAgain ) {
440438 this . _saveAnnotation ( annotation ) ;
441439 } else {
442- this . viewer . _saving [ annotation . id ] = true ;
440+ vsaving [ annotation . id ] = true ;
443441 window . setTimeout ( ( ) => {
444442 if ( annotation . _saveAgain !== undefined && annotation . _saveAgain !== false ) {
445443 this . _saveAnnotation ( annotation ) ;
446444 }
447445 } , annotation . _saveAgain * 1000 ) ;
448446 }
449447 }
450- if ( Object . keys ( this . viewer . _saving ) . length === 1 && this . viewer . _saving . refresh ) {
448+ if ( Object . keys ( vsaving ) . length === 1 && vsaving . refresh ) {
451449 this . _refreshAnnotations ( ) ;
452450 }
453- if ( ! Object . keys ( this . viewer . _saving ) . length || ( Object . keys ( this . viewer . _saving ) . length === 1 && this . viewer . _saving . refresh ) ) {
451+ if ( ! Object . keys ( vsaving ) . length || ( Object . keys ( vsaving ) . length === 1 && vsaving . refresh ) ) {
454452 this . $el . removeClass ( 'saving' ) ;
455453 }
456454 } ) ;
@@ -465,14 +463,14 @@ var AnnotationSelector = Panel.extend({
465463 }
466464 } else {
467465 annotation . _saveAgain = false ;
468- delete this . viewer . _saving [ annotation . id ] ;
466+ delete vsaving [ annotation . id ] ;
469467 if ( annotation . elements ( ) . models . filter ( ( model ) => model . get ( 'type' ) === 'pixelmap' ) . length === 0 ) {
470468 this . trigger ( 'h:redraw' , annotation ) ;
471469 }
472- if ( Object . keys ( this . viewer . _saving ) . length === 1 && this . viewer . _saving . refresh ) {
470+ if ( Object . keys ( vsaving ) . length === 1 && vsaving . refresh ) {
473471 this . _refreshAnnotations ( ) ;
474472 }
475- if ( ! Object . keys ( this . viewer . _saving ) . length || ( Object . keys ( this . viewer . _saving ) . length === 1 && this . viewer . _saving . refresh ) ) {
473+ if ( ! Object . keys ( vsaving ) . length || ( Object . keys ( vsaving ) . length === 1 && vsaving . refresh ) ) {
476474 this . $el . removeClass ( 'saving' ) ;
477475 }
478476 }
0 commit comments