Skip to content

Commit d486782

Browse files
committed
convert app.js to app.tsx
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
1 parent 7ffa1ba commit d486782

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

src/@types/global.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ limitations under the License.
1515
*/
1616

1717
import "matrix-react-sdk/src/@types/global"; // load matrix-react-sdk's type extensions first
18-
import {Renderer} from "react-dom";
18+
import type MatrixChat from "matrix-react-sdk/src/components/structures/MatrixChat";
1919

2020
declare global {
2121
interface Window {
2222
mxSendRageshake: (text: string, withLogs?: boolean) => void;
23-
matrixChat: ReturnType<Renderer>;
23+
matrixChat: MatrixChat;
2424

2525
// electron-only
2626
ipcRenderer: any;
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ limitations under the License.
1919
*/
2020

2121
import 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

2626
import * as sdk from 'matrix-react-sdk';
2727
import PlatformPeg from 'matrix-react-sdk/src/PlatformPeg';
@@ -40,11 +40,11 @@ import SdkConfig from "matrix-react-sdk/src/SdkConfig";
4040

4141
import 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

Comments
 (0)