@@ -19,9 +19,9 @@ limitations under the License.
1919*/
2020
2121import React from 'react' ;
22- // add React and ReactPerf to the global namespace, to make them easier to
23- // access via the console
24- global . React = React ;
22+ // add React and ReactPerf to the global namespace, to make them easier to access via the console
23+ // this incidentally means we can forget our React imports in JSX files without penalty.
24+ window . React = React ;
2525
2626import * as sdk from 'matrix-react-sdk' ;
2727import PlatformPeg from 'matrix-react-sdk/src/PlatformPeg' ;
@@ -40,11 +40,11 @@ import SdkConfig from "matrix-react-sdk/src/SdkConfig";
4040
4141import CallHandler from 'matrix-react-sdk/src/CallHandler' ;
4242
43- let lastLocationHashSet = null ;
43+ let lastLocationHashSet : string = null ;
4444
4545// Parse the given window.location and return parameters that can be used when calling
4646// MatrixChat.showScreen(screen, params)
47- function getScreenFromLocation ( location ) {
47+ function getScreenFromLocation ( location : Location ) {
4848 const fragparts = parseQsFromFragment ( location ) ;
4949 return {
5050 screen : fragparts . location . substring ( 1 ) ,
@@ -54,15 +54,15 @@ function getScreenFromLocation(location) {
5454
5555// Here, we do some crude URL analysis to allow
5656// deep-linking.
57- function routeUrl ( location ) {
57+ function routeUrl ( location : Location ) {
5858 if ( ! window . matrixChat ) return ;
5959
6060 console . log ( "Routing URL " , location . href ) ;
6161 const s = getScreenFromLocation ( location ) ;
6262 window . matrixChat . showScreen ( s . screen , s . params ) ;
6363}
6464
65- function onHashChange ( ev ) {
65+ function onHashChange ( ev : HashChangeEvent ) {
6666 if ( decodeURIComponent ( window . location . hash ) === lastLocationHashSet ) {
6767 // we just set this: no need to route it!
6868 return ;
@@ -72,8 +72,8 @@ function onHashChange(ev) {
7272
7373// This will be called whenever the SDK changes screens,
7474// so a web page can update the URL bar appropriately.
75- function onNewScreen ( screen ) {
76- console . log ( "newscreen " + screen ) ;
75+ function onNewScreen ( screen : string ) {
76+ console . log ( "newscreen " + screen ) ;
7777 const hash = '#/' + screen ;
7878 lastLocationHashSet = hash ;
7979 window . location . hash = hash ;
@@ -88,7 +88,7 @@ function onNewScreen(screen) {
8888// If we're in electron, we should never pass through a file:// URL otherwise
8989// the identity server will try to 302 the browser to it, which breaks horribly.
9090// so in that instance, hardcode to use riot.im/app for now instead.
91- function makeRegistrationUrl ( params ) {
91+ function makeRegistrationUrl ( params : object ) {
9292 let url ;
9393 if ( window . location . protocol === "vector:" ) {
9494 url = 'https://riot.im/app/#/register' ;
@@ -121,8 +121,7 @@ function onTokenLoginCompleted() {
121121 const parsedUrl = url . parse ( window . location . href ) ;
122122 parsedUrl . search = "" ;
123123 const formatted = url . format ( parsedUrl ) ;
124- console . log ( "Redirecting to " + formatted + " to drop loginToken " +
125- "from queryparams" ) ;
124+ console . log ( `Redirecting to ${ formatted } to drop loginToken from queryparams` ) ;
126125 window . location . href = formatted ;
127126}
128127
0 commit comments