mozilla/talkilla — pull request #327 by Standard8 (2013-11-22 11:00:00+00:00)
Title: Remove unnecessary toJSON calls, and simplify message sending when opening the conversation window

This removes the unnecessary toJSON() calls that we were doing for the message payloads.

It also reworks some of the conversation window opening to fix an issue that removing the toJSON call highlighted. The basic issue was that we were trying to pass a generic "context" to the Conversation object. This could have been one of two things, a payloads.offer or an object containing {user: , peer: }.

In removing the toJSON() call, the payloads.offer object would not store and send the additional parameters that were being force into it.

Hence, we now pass explicit parameters to the Conversation object - spa, peer and offer. Although in some cases this duplicates the peer, it feels much better that we're explicit about the parts.

The Conversation window then formulates explicit messages to send to the conversation window.

Also removed in this PR is sending of login-success to the conversation window - as it is no longer required - and sending of the logged in user from the sidebar through to the conversation window - also not required as the worker knows this information.