From b9bbf02b364a4f978530550c465a618e829e89a9 Mon Sep 17 00:00:00 2001 From: inespew Date: Tue, 5 May 2015 13:09:14 +0200 Subject: [PATCH 1/2] session.isClient fix --- togetherjs/session.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/togetherjs/session.js b/togetherjs/session.js index 62e6006a0..a559f3d9a 100644 --- a/togetherjs/session.js +++ b/togetherjs/session.js @@ -329,7 +329,8 @@ define(["require", "util", "channels", "jquery", "storage"], function (require, return; } else if (TogetherJS.startup._launch) { if (saved) { - isClient = saved.reason == "joined"; + var isClientKey = storage.tab.prefix + "isClient"; + isClient = JSON.parse(storage.tab.storage[isClientKey]); if (! shareId) { shareId = saved.shareId; } @@ -450,6 +451,11 @@ define(["require", "util", "channels", "jquery", "storage"], function (require, if (includeHashInUrl) { $(window).on("hashchange", hashchangeEvent); } + storage.tab.get("isClient").then(function(client) { + if (typeof (client) === "undefined") { + storage.tab.set("isClient", session.isClient); + } + }); }); session.on("close", function () { From 66e5f58ea187b8a76cd3e710019cbbdb0fef78d9 Mon Sep 17 00:00:00 2001 From: inespew Date: Wed, 6 May 2015 08:18:42 +0200 Subject: [PATCH 2/2] clean code and change variable declaration --- togetherjs/session.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/togetherjs/session.js b/togetherjs/session.js index a559f3d9a..7a7ae747b 100644 --- a/togetherjs/session.js +++ b/togetherjs/session.js @@ -278,6 +278,7 @@ define(["require", "util", "channels", "jquery", "storage"], function (require, var isClient = true; var set = true; var sessionId; + var isClientKey; session.firstRun = ! TogetherJS.startup.continued; if (! shareId) { if (TogetherJS.startup._joinShareId) { @@ -329,7 +330,7 @@ define(["require", "util", "channels", "jquery", "storage"], function (require, return; } else if (TogetherJS.startup._launch) { if (saved) { - var isClientKey = storage.tab.prefix + "isClient"; + isClientKey = storage.tab.prefix + 'isClient'; isClient = JSON.parse(storage.tab.storage[isClientKey]); if (! shareId) { shareId = saved.shareId; @@ -451,9 +452,9 @@ define(["require", "util", "channels", "jquery", "storage"], function (require, if (includeHashInUrl) { $(window).on("hashchange", hashchangeEvent); } - storage.tab.get("isClient").then(function(client) { - if (typeof (client) === "undefined") { - storage.tab.set("isClient", session.isClient); + storage.tab.get('isClient').then(function(client) { + if (typeof (client) === 'undefined') { + storage.tab.set('isClient', session.isClient); } }); });