Convert PlatformPeg to Typescript

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2020-07-02 22:42:28 +01:00
parent 97711032d8
commit 7322aaf602
2 changed files with 10 additions and 7 deletions

View file

@ -20,6 +20,7 @@ import { IMatrixClientPeg } from "../MatrixClientPeg";
import ToastStore from "../stores/ToastStore"; import ToastStore from "../stores/ToastStore";
import DeviceListener from "../DeviceListener"; import DeviceListener from "../DeviceListener";
import { RoomListStore2 } from "../stores/room-list/RoomListStore2"; import { RoomListStore2 } from "../stores/room-list/RoomListStore2";
import { PlatformPeg } from "../PlatformPeg";
declare global { declare global {
interface Window { interface Window {
@ -33,6 +34,7 @@ declare global {
mx_ToastStore: ToastStore; mx_ToastStore: ToastStore;
mx_DeviceListener: DeviceListener; mx_DeviceListener: DeviceListener;
mx_RoomListStore2: RoomListStore2; mx_RoomListStore2: RoomListStore2;
mxPlatformPeg: PlatformPeg;
} }
// workaround for https://github.com/microsoft/TypeScript/issues/30933 // workaround for https://github.com/microsoft/TypeScript/issues/30933

View file

@ -1,5 +1,6 @@
/* /*
Copyright 2016 OpenMarket Ltd Copyright 2016 OpenMarket Ltd
Copyright 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -14,6 +15,8 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import BasePlatform from "./BasePlatform";
/* /*
* Holds the current Platform object used by the code to do anything * Holds the current Platform object used by the code to do anything
* specific to the platform we're running on (eg. web, electron) * specific to the platform we're running on (eg. web, electron)
@ -21,10 +24,8 @@ limitations under the License.
* This allows the app layer to set a Platform without necessarily * This allows the app layer to set a Platform without necessarily
* having to have a MatrixChat object * having to have a MatrixChat object
*/ */
class PlatformPeg { export class PlatformPeg {
constructor() { platform: BasePlatform = null;
this.platform = null;
}
/** /**
* Returns the current Platform object for the application. * Returns the current Platform object for the application.
@ -44,7 +45,7 @@ class PlatformPeg {
} }
} }
if (!global.mxPlatformPeg) { if (!window.mxPlatformPeg) {
global.mxPlatformPeg = new PlatformPeg(); window.mxPlatformPeg = new PlatformPeg();
} }
export default global.mxPlatformPeg; export default window.mxPlatformPeg;