Skip to content

Commit

Permalink
fix(app): Log with appId as soon as it has one
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Spitzer committed Aug 22, 2018
1 parent 3efa969 commit caed413
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ export function app() {
function handleConnack({ data: message, source: sourceWindow }) {
appId = message.target || '';
token = message.token || '';
debug = log('ts:io:sub:' + appId);

debug('CONNECTED %o', message);

const queueLength = flushQueue(message.token);
if (queueLength) {
Expand All @@ -229,7 +232,6 @@ export function app() {
*/
const eventHandler = event => {
const message = event.data;
debug = log('ts:io:sub:' + appId);
// Only accept messages from the hub in window.top.
if (event.source !== window.top || !appMessageValid(message)) {
return;
Expand All @@ -240,7 +242,7 @@ export function app() {
}

// Call the matching handlers for the message topic.
if (message.type !== 'PING') {
if (!['PING', 'CONNACK'].includes(message.type)) {
debug(
'Received %s %s from %o - %O',
message.type,
Expand All @@ -252,7 +254,6 @@ export function app() {

switch (message.type) {
case 'CONNACK':
debug('CONNECTED %o', message);
handleConnack(event);
if (message.source) {
handleSpawn(event);
Expand Down

0 comments on commit caed413

Please sign in to comment.