Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
kegsay committed Sep 16, 2024
1 parent bd3f9f7 commit 581b419
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
27 changes: 14 additions & 13 deletions src/models/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export type Hero = {
userId: string;
displayName?: string;
avatarUrl?: string;
}
};

export type RoomEventHandlerMap = {
/**
Expand Down Expand Up @@ -959,24 +959,25 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
if (member) {
return member;
}
}
else {
} else {
// use the Hero supplied values for the room member.
// TODO: It's unfortunate that this function, which clearly only cares about the
// avatar url, returns the entire RoomMember event. We need to fake an event
// to meet this API shape.
const heroMember = new RoomMember(this.roomId, hero.userId);
// set the display name and avatar url
heroMember.setMembershipEvent(new MatrixEvent({
// ensure it's unique even if we hit the same millisecond
event_id: "$" + this.roomId + hero.userId + new Date().getTime(),
type: EventType.RoomMember,
state_key: hero.userId,
content: {
displayname: hero.displayName,
avatar_url: hero.avatarUrl,
}
}));
heroMember.setMembershipEvent(
new MatrixEvent({
// ensure it's unique even if we hit the same millisecond
event_id: "$" + this.roomId + hero.userId + new Date().getTime(),
type: EventType.RoomMember,
state_key: hero.userId,
content: {
displayname: hero.displayName,
avatar_url: hero.avatarUrl,
},
}),
);
return heroMember;
}
}
Expand Down
16 changes: 9 additions & 7 deletions src/sliding-sync-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -722,13 +722,15 @@ export class SlidingSyncSdk {
room.updateMyMembership(KnownMembership.Join);

room.setSummary({
"m.heroes": roomData.heroes?.map((h) => {
return {
userId: h.user_id,
avatarUrl: h.avatar_url,
displayName: h.displayname,
};
}),
"m.heroes": roomData.heroes
? roomData.heroes.map((h) => {
return {
userId: h.user_id,
avatarUrl: h.avatar_url,
displayName: h.displayname,
};
})
: [],
"m.invited_member_count": roomData.invited_count,
"m.joined_member_count": roomData.joined_count,
});
Expand Down
2 changes: 1 addition & 1 deletion src/sliding-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export interface MSC3575RoomData {
name: string;
required_state: IStateEvent[];
timeline: (IRoomEvent | IStateEvent)[];
heroes: MSC4186Hero[];
heroes?: MSC4186Hero[];
notification_count?: number;
highlight_count?: number;
joined_count?: number;
Expand Down

0 comments on commit 581b419

Please sign in to comment.