From 48531785a964b2293af8781e1e44f75edfda43d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 21 Jan 2012 22:49:15 +0100 Subject: [PATCH] TimWolla.WCF.Chat.notify is added as event And we notify only when the window is not focused and notifications are active --- file/js/TimWolla.WCF.Chat.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index b83a6a5..1b8bf2c 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -21,9 +21,11 @@ TimWolla.WCF ?= {} init: () -> console.log('[TimWolla.WCF.Chat] Initializing'); @bindEvents() - @refreshRoomList() + @events.newMessage.add $.proxy @notify, @ + new WCF.PeriodicalExecuter $.proxy(@refreshRoomList, @), 60e3 new WCF.PeriodicalExecuter $.proxy(@getMessages, @), @config.reloadTime * 1000 + @refreshRoomList() @getMessages() console.log '[TimWolla.WCF.Chat] Finished initializing' @@ -171,7 +173,6 @@ TimWolla.WCF ?= {} handleMessages: (messages) -> for message in messages @events.newMessage.fire message - @notify message output = @messageTemplate.fetch message li = $ '
  • ' @@ -246,7 +247,7 @@ TimWolla.WCF ?= {} # @param object message ### notify: (message) -> - #return if (@isActive or $('#chatNotify').data('status') is 0) + return if (@isActive or $('#chatNotify').data('status') is 0) @newMessageCount++ document.title = @newMessageCount + ' ' + WCF.Language.get('wcf.chat.newMessages') + ' - ' + @titleTemplate.fetch({ title: $('#chatRoomList .activeMenuItem a').text() })