Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix: follow participant name and generate avatar when partcipant don'…
Browse files Browse the repository at this point in the history
…t have it
  • Loading branch information
carlossantos74 committed Jul 17, 2024
1 parent cdc1d7a commit 3e29e5e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/who-is-online/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ describe('Who Is Online', () => {

expect(whoIsOnlineComponent['room'].emit).toHaveBeenCalledWith(
WhoIsOnlineEvent.START_FOLLOW_ME,
event.detail.id,
event.detail,
);
});
});
Expand Down
17 changes: 15 additions & 2 deletions src/components/who-is-online/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,27 @@ export class WhoIsOnline extends BaseComponent {

this.room.presence.get((list) => {
const dataList = list
.filter((participant) => participant.data['id'] && participant.data['avatar'])
.filter((participant) => participant.data['id'])
.map(({ data }: { data: any }) => {
let avatar = data.avatar;

if (!avatar) {
avatar = this.getAvatar({
avatar: data.avatar,
color: data.slot.color,
name: data.name,
letterColor: data.slot.textColor,
});
}

const tooltip = this.getTooltipData(data);
const controls = this.getControls(data);

return {
...data,
tooltip,
controls,
avatar,
isLocalParticipant: data.id === this.localParticipantId,
};
}) as WhoIsOnlineParticipant[];
Expand Down Expand Up @@ -433,7 +446,7 @@ export class WhoIsOnline extends BaseComponent {
private follow = ({ detail }: CustomEvent) => {
const { everyoneFollowsMe } = this.useStore(StoreType.WHO_IS_ONLINE);
everyoneFollowsMe.publish(!!detail?.id);
this.room.emit(WhoIsOnlineEvent.START_FOLLOW_ME, detail?.id);
this.room.emit(WhoIsOnlineEvent.START_FOLLOW_ME, detail);

if (this.following) {
this.publish(WhoIsOnlineEvent.START_FOLLOW_ME, this.following);
Expand Down

0 comments on commit 3e29e5e

Please sign in to comment.