fix(bug): call._setPrimary should set _primary before _emit is sent #109
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Ran into this while testing out multiple call handling. This fixes a subtle bug where we set _primary after sending the event so the event and the call list didn't have a primary call set. This is due to the
this._emit('promoted', this)
being called before we set the call to primary and so all the data in the event has no primary call set.My argument for doing this is that at this point the call has become the primary and should be reported as such with the event. The
call.demoted
logic follows the same pattern and setsthis.primary = false
before sending thedemoted
event.Scenario:
A
,B
). One is on hold (B
) while the primary (A
) is either on hold or not (it doesn't matter).lwpCallList.switchCall(B.callId())
to makeB
the active callA
gets put on holdB
is promoted to primary and no longer on holdcall.promoted
event forB
Expected:
call.isPrimary()
forB
returns true_lwp.getCallList()
returns a list of calls[A, B]
andB.isPrimary() === true
Actual
call.isPrimary()
forB
returns false_lwp.getCallList()
returns a list of calls[A, B]
andB.isPrimary() === false