@@ -19,7 +19,7 @@ import { MatrixCapabilities, WidgetApi } from "matrix-widget-api";
19
19
import { widgetId } from "./widgets" ;
20
20
import { formatDuration , getAttr } from "./common" ;
21
21
22
- const upvoteEl = document . getElementById ( "upvoted" ) ;
22
+ const upvoteEl = document . getElementById ( "upvoted" ) ! ;
23
23
24
24
interface Scoreboard {
25
25
qaStartTime : number | null ;
@@ -35,7 +35,7 @@ interface RoomMessage {
35
35
senderAvatarHttpUrl ?: string ;
36
36
}
37
37
38
- let widgetApi : WidgetApi = null ;
38
+ let widgetApi : WidgetApi | null = null ;
39
39
40
40
// Start widget API as early as possible
41
41
if ( widgetId ) {
@@ -44,12 +44,12 @@ if (widgetId) {
44
44
widgetApi . requestCapability ( MatrixCapabilities . MSC2931Navigate ) ;
45
45
widgetApi . start ( ) ;
46
46
await new Promise < void > ( resolve => {
47
- widgetApi . once ( "ready" , ( ) => resolve ( ) ) ;
47
+ widgetApi ! . once ( "ready" , ( ) => resolve ( ) ) ;
48
48
} ) ;
49
49
} ) ( ) ;
50
50
}
51
51
52
- const forRoomId = getAttr ( 'org.matrix.confbot.room_id' ) ;
52
+ const forRoomId = getAttr ( 'org.matrix.confbot.room_id' ) ! ;
53
53
54
54
function innerText ( tag : string , clazz : string , text : string ) : [ string , string [ ] ] {
55
55
const id = Date . now ( ) + '-' + ( Math . random ( ) * Number . MAX_SAFE_INTEGER ) + '-text' ;
@@ -68,11 +68,11 @@ function render(scoreboard: Scoreboard) {
68
68
clearInterval ( bannerUpdateTimer ) ;
69
69
bannerUpdateTimer = null ;
70
70
}
71
+ const banner = document . getElementById ( 'scoreboardQABanner' ) ! ;
71
72
if ( scoreboard . qaStartTime !== null ) {
72
73
// Show the countdown banner
73
74
function renderBannerText ( qaStartTime : number ) {
74
75
const timeUntilStart = qaStartTime - Date . now ( ) ;
75
- const banner = document . getElementById ( 'scoreboardQABanner' ) ;
76
76
if ( timeUntilStart < 0 ) {
77
77
banner . innerText = "Q&A has started" ;
78
78
} else {
@@ -84,10 +84,10 @@ function render(scoreboard: Scoreboard) {
84
84
}
85
85
bannerUpdateTimer = window . setInterval ( renderBannerText , 100 , scoreboard . qaStartTime ) ;
86
86
renderBannerText ( scoreboard . qaStartTime ) ;
87
- document . getElementById ( 'scoreboardQABanner' ) . style . display = 'block' ;
87
+ banner . style . display = 'block' ;
88
88
} else {
89
89
// Hide the countdown banner
90
- document . getElementById ( 'scoreboardQABanner' ) . style . display = 'none' ;
90
+ banner . style . display = 'none' ;
91
91
}
92
92
93
93
let html = "" ;
@@ -124,7 +124,7 @@ function render(scoreboard: Scoreboard) {
124
124
}
125
125
upvoteEl . innerHTML = html ;
126
126
for ( const innerText of innerTexts ) {
127
- document . getElementById ( innerText [ 0 ] ) . innerText = innerText [ 1 ] ;
127
+ document . getElementById ( innerText [ 0 ] ) ! . innerText = innerText [ 1 ] ;
128
128
}
129
129
}
130
130
@@ -140,7 +140,7 @@ function intercept(ev) {
140
140
141
141
ev . preventDefault ( ) ;
142
142
ev . stopPropagation ( ) ;
143
- widgetApi . navigateTo ( ev . target . href ) ;
143
+ widgetApi ! . navigateTo ( ev . target . href ) ;
144
144
}
145
145
( < any > window ) . intercept = intercept ;
146
146
0 commit comments