diff --git a/client/dcwebui.js b/client/dcwebui.js index f4751de..2aa4ce7 100644 --- a/client/dcwebui.js +++ b/client/dcwebui.js @@ -489,16 +489,25 @@ var tab_addHandlers = function() { /* */ -var writerFor = function(username) { - var tabid = ""; +var maybeWriterFor = function(username) { if (! username in pm_tabs || ! pm_tabs[username]) { - tabid = tab_new(next_tabid++, username); - pm_tabs[username] = tabid; - } else { - tabid = pm_tabs[username]; + return null; } - return write(tabid); + return write(pm_tabs[username]); +}; + +var writerFor = function(username) { + var ret = maybeWriterFor(username); + + if (ret === null) { + // create new + tabid = tab_new(next_tabid++, username); + pm_tabs[username] = tabid; + return write(tabid); + } + + return ret; }; /* */ @@ -924,6 +933,12 @@ window.onload = function() { if (show_joins) { write("tab-main").system("*** Parts: "+u.user); // sanitised } + + var targetTab = maybeWriterFor(u.user); + if (targetTab !== null) { + targetTab.system("*** Parts: "+u.user); + } + updateTitle(); }); sock.on('join', function(u) { @@ -931,6 +946,12 @@ window.onload = function() { if (show_joins) { write("tab-main").system("*** Joins: "+u.user); } + + var targetTab = maybeWriterFor(u.user); + if (targetTab !== null) { + targetTab.system("*** Joins: "+u.user); + } + updateTitle(); }); sock.on('info', function(u) {