From d84f3cc005caf266b0d6eeb44450e7a2f80f8dc1 Mon Sep 17 00:00:00 2001 From: David Petersen Date: Sat, 3 Mar 2012 12:52:06 -0800 Subject: [PATCH] Get messages from notice --- assets/js/client.js | 19 ++++++++++++++++--- assets/js/views/chat_application.js | 2 -- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/assets/js/client.js b/assets/js/client.js index 04ecb22..db8d8ee 100644 --- a/assets/js/client.js +++ b/assets/js/client.js @@ -41,10 +41,15 @@ $(function() { // Registration (server joined) irc.socket.on('registered', function(data) { + var window = irc.chatWindows.getByName('status'); irc.socket.emit('getNick', {}); irc.connected = true; - irc.appView.render(); - irc.chatWindows.add({name: 'status', type: 'status'}); + if(window === undefined){ + irc.appView.render(); + irc.chatWindows.add({name: 'status', type: 'status'}); + } else { + irc.appView.renderUserBox(); + } // Will reflect modified nick, if chosen nick was taken already irc.me.set('nick', data.message.args[0]); @@ -101,7 +106,15 @@ $(function() { irc.socket.on('notice', function(data) { //TODO: make this work - //irc.chatWindows.getByName('status').stream.add({sender: 'notice', raw: data.text, type: 'notice'}); + var window = irc.chatWindows.getByName('status'); + if(window === undefined){ + irc.connected = true; + irc.appView.render(); + irc.chatWindows.add({name: 'status', type: 'status'}); + window = irc.chatWindows.getByName('status'); + } + var sender = (data.nick !== undefined) ? data.nick : 'notice'; + window.stream.add({sender: sender, raw: data.text, type: 'notice'}); }); // Message of the Day diff --git a/assets/js/views/chat_application.js b/assets/js/views/chat_application.js index 490bcc3..b66dbd5 100644 --- a/assets/js/views/chat_application.js +++ b/assets/js/views/chat_application.js @@ -42,8 +42,6 @@ var ChatApplicationView = Backbone.View.extend({ var overview = new OverviewView; } else { this.channelList = new ChannelListView; - // irc.me.on('change:nick', this.renderUserBox, this); - this.renderUserBox(); } return this; },