瀏覽代碼

Changed the following:
- Removed situation where extra data passed in keyPressed was overriden
with the same result because of the two assignments inside the if
statements
- Cached fullname and presence_type at initialize of ChatBoxView

ichim-david 12 年之前
父節點
當前提交
5c5b7b9dd7
共有 1 個文件被更改,包括 10 次插入9 次删除
  1. 10 9
      converse.js

+ 10 - 9
converse.js

@@ -519,7 +519,6 @@
                         notify = $msg({'to':this.model.get('jid'), 'type': 'chat'})
                                         .c('composing', {'xmlns':'http://jabber.org/protocol/chatstates'});
                         xmppchat.connection.send(notify);
-                        this.$el.data('composing', true);
                     }
                     this.$el.data('composing', true);
                 }
@@ -542,19 +541,21 @@
         },
 
         initialize: function (){
-            $('body').append($(this.el).hide());
+            $('body').append(this.$el.hide());
 
             xmppchat.roster.on('change', function (item, changed) {
+                var fullname = this.model.get('fullname'),
+                    presence_type = item.get('presence_type');
                 if (item.get('jid') ===  this.model.get('jid')) {
                     if (_.has(changed.changes, 'presence_type')) {
                         if (this.$el.is(':visible')) {
-                            if (item.get('presence_type') === 'offline') {
-                                this.insertStatusNotification(this.model.get('fullname')+' '+'has gone offline');
-                            } else if (item.get('presence_type') === 'away') {
-                                this.insertStatusNotification(this.model.get('fullname')+' '+'has gone away');
-                            } else if ((item.get('presence_type') === 'busy') || (item.get('presence_type') === 'dnd')) {
-                                this.insertStatusNotification(this.model.get('fullname')+' '+'is busy');
-                            } else if (item.get('presence_type') === 'online') {
+                            if (presence_type === 'offline') {
+                                this.insertStatusNotification(fullname+' '+'has gone offline');
+                            } else if (presence_type === 'away') {
+                                this.insertStatusNotification(fullname+' '+'has gone away');
+                            } else if ((presence_type === 'busy') || (presence_type === 'dnd')) {
+                                this.insertStatusNotification(fullname+' '+'is busy');
+                            } else if (presence_type === 'online') {
                                 this.$el.find('div.chat-event').remove();
                             }
                         }