@@ -31,10 +31,10 @@ class Main {
3131 properties : Array < string [ ] > ;
3232 notes : string [ ] ;
3333
34- currentId : string = null ;
35- currentLang : string = null ;
36- currentCell : HTMLTableCellElement = null ;
37- currentContent : string = null ;
34+ currentId : string ;
35+ currentLang : string ;
36+ currentCell : HTMLTableCellElement ;
37+ currentContent : string ;
3838 selectedUnits : string [ ] = [ ] ;
3939
4040 static EDIT : string = '<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">' +
@@ -74,16 +74,16 @@ class Main {
7474 this . deleteUnits ( ) ;
7575 } ) ;
7676 this . electron . ipcRenderer . on ( 'sort-on' , ( ) => {
77- document . getElementById ( 'sortUnits' ) . classList . add ( 'active' ) ;
77+ ( document . getElementById ( 'sortUnits' ) as HTMLAnchorElement ) . classList . add ( 'active' ) ;
7878 } ) ;
7979 this . electron . ipcRenderer . on ( 'sort-off' , ( ) => {
80- document . getElementById ( 'sortUnits' ) . classList . remove ( 'active' ) ;
80+ ( document . getElementById ( 'sortUnits' ) as HTMLAnchorElement ) . classList . remove ( 'active' ) ;
8181 } ) ;
8282 this . electron . ipcRenderer . on ( 'filters-on' , ( ) => {
83- document . getElementById ( 'filterUnits' ) . classList . add ( 'active' ) ;
83+ ( document . getElementById ( 'filterUnits' ) as HTMLAnchorElement ) . classList . add ( 'active' ) ;
8484 } ) ;
8585 this . electron . ipcRenderer . on ( 'filters-off' , ( ) => {
86- document . getElementById ( 'filterUnits' ) . classList . remove ( 'active' ) ;
86+ ( document . getElementById ( 'filterUnits' ) as HTMLAnchorElement ) . classList . remove ( 'active' ) ;
8787 } ) ;
8888 this . electron . ipcRenderer . on ( 'start-waiting' , ( ) => {
8989 document . body . classList . add ( "wait" ) ;
@@ -361,7 +361,7 @@ class Main {
361361 event . cancelBubble = true ;
362362 this . lastPage ( ) ;
363363 }
364- if ( this . currentCell !== null && ( event . key === 'PageDown' || event . key === 'PageUp' ) && ! ( event . ctrlKey || event . metaKey ) ) {
364+ if ( this . currentCell && ( event . key === 'PageDown' || event . key === 'PageUp' ) && ! ( event . ctrlKey || event . metaKey ) ) {
365365 // prevent scrolling while editing
366366 event . preventDefault ( ) ;
367367 event . cancelBubble = true ;
@@ -859,7 +859,7 @@ class Main {
859859 if ( ! this . isLoaded ) {
860860 return ;
861861 }
862- if ( this . currentId === null || this . currentId === '' ) {
862+ if ( ! this . currentId || this . currentId === null || this . currentId === '' ) {
863863 return ;
864864 }
865865 this . electron . ipcRenderer . send ( 'edit-attributes' , { id : this . currentId , atts : this . attributes , type : this . attributesType } ) ;
@@ -869,7 +869,7 @@ class Main {
869869 if ( ! this . isLoaded ) {
870870 return ;
871871 }
872- if ( this . currentId === null || this . currentId === '' ) {
872+ if ( ! this . currentId || this . currentId === null || this . currentId === '' ) {
873873 return ;
874874 }
875875 this . electron . ipcRenderer . send ( 'edit-properties' , { id : this . currentId , props : this . properties , type : this . attributesType } ) ;
@@ -879,7 +879,7 @@ class Main {
879879 if ( ! this . isLoaded ) {
880880 return ;
881881 }
882- if ( this . currentId === null || this . currentId === '' ) {
882+ if ( ! this . currentId || this . currentId === null || this . currentId === '' ) {
883883 return ;
884884 }
885885 this . electron . ipcRenderer . send ( 'edit-notes' , { id : this . currentId , notes : this . notes , type : this . attributesType } ) ;
@@ -952,10 +952,10 @@ class Main {
952952 this . maxPage = 0 ;
953953 this . isLoaded = false ;
954954
955- this . currentId = null ;
956- this . currentLang = null ;
957- this . currentCell = null ;
958- this . currentContent = null ;
955+ this . currentId = undefined ;
956+ this . currentLang = undefined ;
957+ this . currentCell = undefined ;
958+ this . currentContent = undefined ;
959959 this . selectedUnits = [ ] ;
960960 }
961961
@@ -983,7 +983,7 @@ class Main {
983983 document . getElementById ( 'propertiesSpan' ) . innerHTML = 'TU' ;
984984 document . getElementById ( 'notesTable' ) . innerHTML = '' ;
985985 document . getElementById ( 'notesSpan' ) . innerHTML = 'TU' ;
986- this . currentId = null ;
986+ this . currentId = undefined ;
987987 this . setStatus ( '' ) ;
988988 }
989989
@@ -1040,15 +1040,15 @@ class Main {
10401040 }
10411041 lang = ( event . target as Element ) . getAttribute ( 'lang' ) ;
10421042 }
1043- if ( this . currentCell !== null && this . currentCell . isContentEditable && ( this . currentId !== id || this . currentLang !== lang ) ) {
1043+ if ( this . currentCell && this . currentCell . isContentEditable && ( this . currentId !== id || this . currentLang !== lang ) ) {
10441044 this . saveEdit ( ) ;
10451045 }
10461046
10471047 if ( id ) {
10481048 this . currentId = id ;
10491049 if ( this . currentCell ) {
1050- this . currentCell = null ;
1051- this . currentContent = null ;
1050+ this . currentCell = undefined ;
1051+ this . currentContent = undefined ;
10521052 }
10531053 if ( lang ) {
10541054 this . currentLang = lang ;
@@ -1130,7 +1130,7 @@ class Main {
11301130 }
11311131
11321132 firstPage ( ) : void {
1133- if ( this . currentCell !== null && this . currentCell . isContentEditable ) {
1133+ if ( this . currentCell && this . currentCell . isContentEditable ) {
11341134 this . saveEdit ( ) ;
11351135 }
11361136 this . currentPage = 0 ;
@@ -1140,7 +1140,7 @@ class Main {
11401140
11411141 previousPage ( ) : void {
11421142 if ( this . currentPage > 0 ) {
1143- if ( this . currentCell !== null && this . currentCell . isContentEditable ) {
1143+ if ( this . currentCell && this . currentCell . isContentEditable ) {
11441144 this . saveEdit ( ) ;
11451145 }
11461146 this . currentPage -- ;
@@ -1151,7 +1151,7 @@ class Main {
11511151
11521152 nextPage ( ) : void {
11531153 if ( this . currentPage < this . maxPage - 1 ) {
1154- if ( this . currentCell !== null && this . currentCell . isContentEditable ) {
1154+ if ( this . currentCell && this . currentCell . isContentEditable ) {
11551155 this . saveEdit ( ) ;
11561156 }
11571157 this . currentPage ++ ;
@@ -1161,7 +1161,7 @@ class Main {
11611161 }
11621162
11631163 lastPage ( ) : void {
1164- if ( this . currentCell !== null && this . currentCell . isContentEditable ) {
1164+ if ( this . currentCell && this . currentCell . isContentEditable ) {
11651165 this . saveEdit ( ) ;
11661166 }
11671167 this . currentPage = this . maxPage - 1 ;
@@ -1184,7 +1184,7 @@ class Main {
11841184 ( document . getElementById ( 'units_page' ) as HTMLInputElement ) . value = '' + this . unitsPage ;
11851185 this . maxPage = Math . ceil ( this . unitsCount / this . unitsPage ) ;
11861186 document . getElementById ( 'pages' ) . innerText = '' + this . maxPage ;
1187- if ( this . currentCell !== null && this . currentCell . isContentEditable ) {
1187+ if ( this . currentCell && this . currentCell . isContentEditable ) {
11881188 this . saveEdit ( ) ;
11891189 }
11901190 this . firstPage ( ) ;
@@ -1203,7 +1203,7 @@ class Main {
12031203 if ( this . currentPage > this . maxPage - 1 ) {
12041204 this . currentPage = this . maxPage - 1 ;
12051205 }
1206- if ( this . currentCell !== null && this . currentCell . isContentEditable ) {
1206+ if ( this . currentCell && this . currentCell . isContentEditable ) {
12071207 this . saveEdit ( ) ;
12081208 }
12091209 ( document . getElementById ( 'page' ) as HTMLInputElement ) . value = '' + ( this . currentPage + 1 ) ;
0 commit comments