Skip to content

Commit

Permalink
Fix member.updated events (#885)
Browse files Browse the repository at this point in the history
* strip namespace prefix from member.updated event

* changeset

* update tests

* rm debug
  • Loading branch information
Edoardo Gallo authored Sep 20, 2023
1 parent e5db7ca commit bcced8a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-timers-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@signalwire/core': patch
---

Bugfix: remove video prefix from member.updated events to emit them properly
9 changes: 3 additions & 6 deletions packages/core/src/memberPosition/workers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,14 @@ describe('memberPositionWorker', () => {
.run()
.finally(() => {
expect(emitSpy).toHaveBeenCalledWith(
'video.member.updated.visible',
'member.updated.visible',
action.payload
)
expect(emitSpy).toHaveBeenCalledWith(
'video.member.updated.video_muted',
action.payload
)
expect(emitSpy).toHaveBeenCalledWith(
'video.member.updated',
'member.updated.video_muted',
action.payload
)
expect(emitSpy).toHaveBeenCalledWith('member.updated', action.payload)
expect(memberList.get(memberId)?.member.visible).toBe(true)
expect(memberList.get(memberId)?.member.video_muted).toBe(false)
expect(memberList.get(memberId)?.member.updated).toStrictEqual([
Expand Down
14 changes: 6 additions & 8 deletions packages/core/src/memberPosition/workers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
SagaIterator,
SDKWorker,
SDKWorkerParams,
stripNamespacePrefix,
VideoMemberUpdatedEventParams,
VideoPosition,
VideoRoomSubscribedEventParams,
Expand Down Expand Up @@ -60,7 +61,7 @@ function* memberPositionLayoutChangedWorker(options: any) {

for (const [memberId, payload] of memberList) {
if (processedMembers[memberId]) {
yield dispatcher?.('video.member.updated', payload, instance)
yield dispatcher?.('member.updated', payload, instance)

/**
* `undefined` means that we couldn't find the
Expand All @@ -78,11 +79,7 @@ function* memberPositionLayoutChangedWorker(options: any) {
return
}

yield dispatcher?.(
'video.member.updated',
updatedMemberEventParams,
instance
)
yield dispatcher?.('member.updated', updatedMemberEventParams, instance)
}
}
}
Expand Down Expand Up @@ -121,12 +118,13 @@ export function* memberUpdatedWorker({
/** member.updated event is the only one updating the memberList payload */
memberList.set(memberId, memberUpdatedPayload)

const event = stripNamespacePrefix(action.type)
for (const key of updated) {
const type = `${action.type}.${key}` as InternalMemberUpdatedEventNames
const type = `${event}.${key}` as InternalMemberUpdatedEventNames
yield dispatcher?.(type, memberUpdatedPayload, instance)
}

yield dispatcher?.(action.type, memberUpdatedPayload, instance)
yield dispatcher?.(event, memberUpdatedPayload, instance)
}

export const MEMBER_POSITION_COMPOUND_EVENTS = new Map<any, any>([
Expand Down

0 comments on commit bcced8a

Please sign in to comment.