Conform more of the code base to strict null checking (#10147)
* Conform more of the code base to strict null checking * More strict fixes * More strict work * Fix missing optional type * Iterate
This commit is contained in:
parent
fa036a5080
commit
da7aa4055e
380 changed files with 682 additions and 694 deletions
|
@ -44,7 +44,7 @@ const FORCED_USER_REGEX = /[^/,:; \t\n]\S*/g;
|
|||
|
||||
export default class UserProvider extends AutocompleteProvider {
|
||||
public matcher: QueryMatcher<RoomMember>;
|
||||
public users: RoomMember[];
|
||||
public users: RoomMember[] | null;
|
||||
public room: Room;
|
||||
|
||||
public constructor(room: Room, renderingType?: TimelineRenderingType) {
|
||||
|
@ -54,7 +54,7 @@ export default class UserProvider extends AutocompleteProvider {
|
|||
renderingType,
|
||||
});
|
||||
this.room = room;
|
||||
this.matcher = new QueryMatcher([], {
|
||||
this.matcher = new QueryMatcher<RoomMember>([], {
|
||||
keys: ["name"],
|
||||
funcs: [(obj) => obj.userId.slice(1)], // index by user id minus the leading '@'
|
||||
shouldMatchWordsOnly: false,
|
||||
|
@ -73,7 +73,7 @@ export default class UserProvider extends AutocompleteProvider {
|
|||
|
||||
private onRoomTimeline = (
|
||||
ev: MatrixEvent,
|
||||
room: Room | null,
|
||||
room: Room | undefined,
|
||||
toStartOfTimeline: boolean,
|
||||
removed: boolean,
|
||||
data: IRoomTimelineData,
|
||||
|
@ -118,7 +118,7 @@ export default class UserProvider extends AutocompleteProvider {
|
|||
// Don't include the '@' in our search query - it's only used as a way to trigger completion
|
||||
const query = fullMatch.startsWith("@") ? fullMatch.substring(1) : fullMatch;
|
||||
return this.matcher.match(query, limit).map((user) => {
|
||||
const description = UserIdentifierCustomisations.getDisplayUserIdentifier(user.userId, {
|
||||
const description = UserIdentifierCustomisations.getDisplayUserIdentifier?.(user.userId, {
|
||||
roomId: this.room.roomId,
|
||||
withDisplayName: true,
|
||||
});
|
||||
|
@ -129,14 +129,14 @@ export default class UserProvider extends AutocompleteProvider {
|
|||
completion: user.rawDisplayName,
|
||||
completionId: user.userId,
|
||||
type: "user",
|
||||
suffix: selection.beginning && range.start === 0 ? ": " : " ",
|
||||
suffix: selection.beginning && range!.start === 0 ? ": " : " ",
|
||||
href: makeUserPermalink(user.userId),
|
||||
component: (
|
||||
<PillCompletion title={displayName} description={description}>
|
||||
<MemberAvatar member={user} width={24} height={24} />
|
||||
</PillCompletion>
|
||||
),
|
||||
range,
|
||||
range: range!,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ export default class UserProvider extends AutocompleteProvider {
|
|||
const lastSpoken: Record<string, number> = {};
|
||||
|
||||
for (const event of events) {
|
||||
lastSpoken[event.getSender()] = event.getTs();
|
||||
lastSpoken[event.getSender()!] = event.getTs();
|
||||
}
|
||||
|
||||
const currentUserId = MatrixClientPeg.get().credentials.userId;
|
||||
|
@ -164,7 +164,7 @@ export default class UserProvider extends AutocompleteProvider {
|
|||
this.matcher.setObjects(this.users);
|
||||
}
|
||||
|
||||
public onUserSpoke(user: RoomMember): void {
|
||||
public onUserSpoke(user: RoomMember | null): void {
|
||||
if (!this.users) return;
|
||||
if (!user) return;
|
||||
if (user.userId === MatrixClientPeg.get().credentials.userId) return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue