Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 9aff2e8

Browse files
authored
Merge pull request #4593 from matrix-org/travis/dispatcher-types
Convert the dispatcher to TypeScript
2 parents 1eea203 + 798e7a1 commit 9aff2e8

File tree

142 files changed

+682
-481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+682
-481
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
"@babel/register": "^7.7.4",
118118
"@peculiar/webcrypto": "^1.0.22",
119119
"@types/classnames": "^2.2.10",
120+
"@types/flux": "^3.1.9",
120121
"@types/modernizr": "^3.5.3",
121122
"@types/qrcode": "^1.3.4",
122123
"@types/react": "16.9",

src/BasePlatform.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020
*/
2121

2222
import {MatrixClient} from "matrix-js-sdk";
23-
import dis from './dispatcher';
23+
import dis from './dispatcher/dispatcher';
2424
import BaseEventIndexManager from './indexing/BaseEventIndexManager';
2525

2626
/**

src/CallHandler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import Modal from './Modal';
5959
import * as sdk from './index';
6060
import { _t } from './languageHandler';
6161
import Matrix from 'matrix-js-sdk';
62-
import dis from './dispatcher';
62+
import dis from './dispatcher/dispatcher';
6363
import { showUnknownDeviceDialogForCalls } from './cryptodevices';
6464
import WidgetUtils from './utils/WidgetUtils';
6565
import WidgetEchoStore from './stores/WidgetEchoStore';

src/ContentMessages.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818
'use strict';
1919

2020
import extend from './extend';
21-
import dis from './dispatcher';
21+
import dis from './dispatcher/dispatcher';
2222
import {MatrixClientPeg} from './MatrixClientPeg';
2323
import * as sdk from './index';
2424
import { _t } from './languageHandler';

src/FromWidgetPostMessageApi.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
*/
1818

1919
import URL from 'url';
20-
import dis from './dispatcher';
20+
import dis from './dispatcher/dispatcher';
2121
import WidgetMessagingEndpoint from './WidgetMessagingEndpoint';
2222
import ActiveWidgetStore from './stores/ActiveWidgetStore';
2323
import {MatrixClientPeg} from "./MatrixClientPeg";

src/Lifecycle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Analytics from './Analytics';
2626
import Notifier from './Notifier';
2727
import UserActivity from './UserActivity';
2828
import Presence from './Presence';
29-
import dis from './dispatcher';
29+
import dis from './dispatcher/dispatcher';
3030
import DMRoomMap from './utils/DMRoomMap';
3131
import Modal from './Modal';
3232
import * as sdk from './index';

src/Modal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818
import React from 'react';
1919
import ReactDOM from 'react-dom';
2020
import Analytics from './Analytics';
21-
import dis from './dispatcher';
21+
import dis from './dispatcher/dispatcher';
2222
import {defer} from './utils/promise';
2323
import AsyncWrapper from './AsyncWrapper';
2424

src/Notifier.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import PlatformPeg from './PlatformPeg';
2121
import * as TextForEvent from './TextForEvent';
2222
import Analytics from './Analytics';
2323
import * as Avatar from './Avatar';
24-
import dis from './dispatcher';
24+
import dis from './dispatcher/dispatcher';
2525
import * as sdk from './index';
2626
import { _t } from './languageHandler';
2727
import Modal from './Modal';

src/Presence.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
*/
1818

1919
import {MatrixClientPeg} from "./MatrixClientPeg";
20-
import dis from "./dispatcher";
20+
import dis from "./dispatcher/dispatcher";
2121
import Timer from './utils/Timer';
2222

2323
// Time in ms after that a user is considered as unavailable/away

src/Registration.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020
* registration code.
2121
*/
2222

23-
import dis from './dispatcher';
23+
import dis from './dispatcher/dispatcher';
2424
import * as sdk from './index';
2525
import Modal from './Modal';
2626
import { _t } from './languageHandler';

src/Resend.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616
*/
1717

1818
import {MatrixClientPeg} from './MatrixClientPeg';
19-
import dis from './dispatcher';
19+
import dis from './dispatcher/dispatcher';
2020
import { EventStatus } from 'matrix-js-sdk';
2121

2222
export default class Resend {

src/ScalarMessaging.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ Example:
238238

239239
import {MatrixClientPeg} from './MatrixClientPeg';
240240
import { MatrixEvent } from 'matrix-js-sdk';
241-
import dis from './dispatcher';
241+
import dis from './dispatcher/dispatcher';
242242
import WidgetUtils from './utils/WidgetUtils';
243243
import RoomViewStore from './stores/RoomViewStore';
244244
import { _t } from './languageHandler';

src/SlashCommands.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ limitations under the License.
2121
import * as React from 'react';
2222

2323
import {MatrixClientPeg} from './MatrixClientPeg';
24-
import dis from './dispatcher';
24+
import dis from './dispatcher/dispatcher';
2525
import * as sdk from './index';
2626
import {_t, _td} from './languageHandler';
2727
import Modal from './Modal';
@@ -41,6 +41,8 @@ import { parseFragment as parseHtml } from "parse5";
4141
import sendBugReport from "./rageshake/submit-rageshake";
4242
import SdkConfig from "./SdkConfig";
4343
import { ensureDMExists } from "./createRoom";
44+
import { ViewUserPayload } from "./dispatcher/payloads/ViewUserPayload";
45+
import { Action } from "./dispatcher/actions";
4446

4547
// XXX: workaround for https://github.com/microsoft/TypeScript/issues/31816
4648
interface HTMLInputEvent extends Event {
@@ -943,8 +945,10 @@ export const Commands = [
943945
}
944946

945947
const member = MatrixClientPeg.get().getRoom(roomId).getMember(userId);
946-
dis.dispatch({
947-
action: 'view_user',
948+
dis.dispatch<ViewUserPayload>({
949+
action: Action.ViewUser,
950+
// XXX: We should be using a real member object and not assuming what the
951+
// receiver wants.
948952
member: member || {userId},
949953
});
950954
return success();

src/UserActivity.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
import dis from './dispatcher';
18+
import dis from './dispatcher/dispatcher';
1919
import Timer from './utils/Timer';
2020

2121
// important these are larger than the timeouts of timers

src/actions/GroupActions.js

-34
This file was deleted.

src/actions/GroupActions.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Copyright 2017 New Vector Ltd
3+
Copyright 2020 The Matrix.org Foundation C.I.C.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
import { asyncAction } from './actionCreators';
19+
import { AsyncActionPayload } from "../dispatcher/payloads";
20+
import { MatrixClient } from "matrix-js-sdk/src/client";
21+
22+
export default class GroupActions {
23+
/**
24+
* Creates an action thunk that will do an asynchronous request to fetch
25+
* the groups to which a user is joined.
26+
*
27+
* @param {MatrixClient} matrixClient the matrix client to query.
28+
* @returns {AsyncActionPayload} An async action payload.
29+
* @see asyncAction
30+
*/
31+
public static fetchJoinedGroups(matrixClient: MatrixClient): AsyncActionPayload {
32+
return asyncAction('GroupActions.fetchJoinedGroups', () => matrixClient.getJoinedGroups(), null);
33+
}
34+
}

src/actions/MatrixActionCreators.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import dis from '../dispatcher';
17+
import dis from '../dispatcher/dispatcher';
1818

1919
// TODO: migrate from sync_state to MatrixActions.sync so that more js-sdk events
2020
// become dispatches in the same place.

src/actions/RoomListActions.js

-145
This file was deleted.

0 commit comments

Comments
 (0)