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

Commit

Permalink
Merge pull request #679 from SuperViz/fix/initialize-correct-list-wio
Browse files Browse the repository at this point in the history
fix: initialize correct list wio
  • Loading branch information
carlossantos74 authored May 22, 2024
2 parents a9bdcb8 + 229e2ad commit 0fc0dad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
29 changes: 15 additions & 14 deletions src/components/form-elements/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,15 @@ export class FormElements extends BaseComponent {

this.room?.emit(FieldEvents.INTERACTION + target.id, {
fieldId: target.id,
color: this.localParticipant.slot.color,
color: this.localParticipant.slot?.color,
});

const canSync = this.canSyncContent(target.id);
if (!canSync) return;

const payload: InputPayload & FocusPayload = {
value: target.value,
color: this.localParticipant.slot.color,
color: this.localParticipant.slot?.color,
fieldId: target.id,
showOutline: this.canUpdateColor(target.id),
syncContent: canSync,
Expand Down Expand Up @@ -604,16 +604,17 @@ export class FormElements extends BaseComponent {
timestamp,
...params
}: SocketEvent<InputPayload>) => {
if (syncContent && this.canSyncContent(fieldId)) {
this.publish(FieldEvents.CONTENT_CHANGE, {
value,
fieldId,
attribute,
userId: presence.id,
userName: presence.name,
timestamp,
});

if (syncContent && this.canSyncContent(fieldId) && presence.id !== this.localParticipant.id) {
this.fields[fieldId][attribute] = value;
this.publish(FieldEvents.CONTENT_CHANGE, {
value,
fieldId,
attribute,
userId: presence.id,
userName: presence.name,
timestamp,
});
}

if (showOutline && this.canUpdateColor(fieldId)) {
Expand Down Expand Up @@ -659,10 +660,10 @@ export class FormElements extends BaseComponent {
);
}

private canSyncContent(fieldId: string): boolean {
private canSyncContent = (fieldId: string): boolean => {
return (
(!this.flags.disableRealtimeSync && this.enabledRealtimeSyncFields[fieldId] !== false) ||
this.enabledRealtimeSyncFields[fieldId]
!!this.enabledRealtimeSyncFields[fieldId]
);
}
};
}
1 change: 1 addition & 0 deletions src/components/who-is-online/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const generateMockParticipant = ({
name,
disableDropdown,
isPrivate,
avatar: {},
},
};

Expand Down
4 changes: 3 additions & 1 deletion src/components/who-is-online/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class WhoIsOnline extends BaseComponent {

this.room.presence.get((list) => {
const dataList = list
.filter((participant) => participant.data['id'])
.filter((participant) => participant.data['id'] && participant.data['avatar'])
.map(({ data }: { data: any }) => {
const tooltip = this.getTooltipData(data);
const controls = this.getControls(data);
Expand All @@ -183,6 +183,8 @@ export class WhoIsOnline extends BaseComponent {
};
}) as WhoIsOnlineParticipant[];

if (!dataList.length) return;

const localParticipantIndex = dataList.findIndex((participant) => {
return participant.id === this.localParticipantId;
});
Expand Down

0 comments on commit 0fc0dad

Please sign in to comment.