Improve typing around event emitter handlers (#7816)
This commit is contained in:
parent
213b32bf14
commit
7fa01ffb06
79 changed files with 548 additions and 471 deletions
|
@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||
import { ClientEvent, MatrixClient } from "matrix-js-sdk/src/client";
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
|
||||
import { MatrixClientPeg } from '../../MatrixClientPeg';
|
||||
|
@ -46,10 +46,10 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
|
|||
|
||||
public initMatrixClient(oldClient: MatrixClient, newClient: MatrixClient) {
|
||||
if (oldClient) {
|
||||
oldClient.removeListener("accountData", this.onAccountData);
|
||||
oldClient.removeListener(ClientEvent.AccountData, this.onAccountData);
|
||||
}
|
||||
|
||||
newClient.on("accountData", this.onAccountData);
|
||||
newClient.on(ClientEvent.AccountData, this.onAccountData);
|
||||
}
|
||||
|
||||
private onAccountData = (event: MatrixEvent, prevEvent: MatrixEvent) => {
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
|
||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { Room, RoomEvent } from "matrix-js-sdk/src/models/room";
|
||||
|
||||
import { MatrixClientPeg } from '../../MatrixClientPeg';
|
||||
import MatrixClientBackedSettingsHandler from "./MatrixClientBackedSettingsHandler";
|
||||
|
@ -37,10 +37,10 @@ export default class RoomAccountSettingsHandler extends MatrixClientBackedSettin
|
|||
|
||||
protected initMatrixClient(oldClient: MatrixClient, newClient: MatrixClient) {
|
||||
if (oldClient) {
|
||||
oldClient.removeListener("Room.accountData", this.onAccountData);
|
||||
oldClient.removeListener(RoomEvent.AccountData, this.onAccountData);
|
||||
}
|
||||
|
||||
newClient.on("Room.accountData", this.onAccountData);
|
||||
newClient.on(RoomEvent.AccountData, this.onAccountData);
|
||||
}
|
||||
|
||||
private onAccountData = (event: MatrixEvent, room: Room, prevEvent: MatrixEvent) => {
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
|
||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
import { RoomState } from "matrix-js-sdk/src/models/room-state";
|
||||
import { RoomState, RoomStateEvent } from "matrix-js-sdk/src/models/room-state";
|
||||
|
||||
import { MatrixClientPeg } from '../../MatrixClientPeg';
|
||||
import MatrixClientBackedSettingsHandler from "./MatrixClientBackedSettingsHandler";
|
||||
|
@ -35,10 +35,10 @@ export default class RoomSettingsHandler extends MatrixClientBackedSettingsHandl
|
|||
|
||||
protected initMatrixClient(oldClient: MatrixClient, newClient: MatrixClient) {
|
||||
if (oldClient) {
|
||||
oldClient.removeListener("RoomState.events", this.onEvent);
|
||||
oldClient.removeListener(RoomStateEvent.Events, this.onEvent);
|
||||
}
|
||||
|
||||
newClient.on("RoomState.events", this.onEvent);
|
||||
newClient.on(RoomStateEvent.Events, this.onEvent);
|
||||
}
|
||||
|
||||
private onEvent = (event: MatrixEvent, state: RoomState, prevEvent: MatrixEvent) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue