Conform more code to strict null checking (#10169)

* Conform more code to strict null checking

* delint

* Iterate

* delint

* Fix bad test
This commit is contained in:
Michael Telatynski 2023-02-16 09:38:44 +00:00 committed by GitHub
parent 5123d7e641
commit e8b92b308b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
85 changed files with 283 additions and 287 deletions

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import React from "react";
import React, { ReactNode } from "react";
import { Room } from "matrix-js-sdk/src/models/room";
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
@ -34,17 +34,16 @@ interface IProps {
}
export default class BridgeSettingsTab extends React.Component<IProps> {
private renderBridgeCard(event: MatrixEvent, room: Room): JSX.Element {
private renderBridgeCard(event: MatrixEvent, room: Room | null): ReactNode {
const content = event.getContent();
if (!content || !content.channel || !content.protocol) {
return null;
}
if (!room || !content?.channel || !content.protocol) return null;
return <BridgeTile key={event.getId()} room={room} ev={event} />;
}
public static getBridgeStateEvents(roomId: string): MatrixEvent[] {
const client = MatrixClientPeg.get();
const roomState = client.getRoom(roomId).currentState;
const roomState = client.getRoom(roomId)?.currentState;
if (!roomState) return [];
return BRIDGE_EVENT_TYPES.map((typeName) => roomState.getStateEvents(typeName)).flat(1);
}