Browse Source

Extract inline code into method

JC Brand 7 năm trước cách đây
mục cha
commit
cb118b9cd0
1 tập tin đã thay đổi với 12 bổ sung10 xóa
  1. 12 10
      src/converse-muc-views.js

+ 12 - 10
src/converse-muc-views.js

@@ -550,16 +550,7 @@
 
 
                     this.model.occupants.on('add', this.showJoinNotification, this);
                     this.model.occupants.on('add', this.showJoinNotification, this);
                     this.model.occupants.on('remove', this.showLeaveNotification, this);
                     this.model.occupants.on('remove', this.showLeaveNotification, this);
-                    this.model.occupants.on('change:show', (occupant) => {
-                        if (!occupant.isMember() || _.includes(occupant.get('states'), '303')) {
-                            return;
-                        }
-                        if (occupant.get('show') === 'offline') {
-                            this.showLeaveNotification(occupant);
-                        } else if (occupant.get('show') === 'online') {
-                            this.showJoinNotification(occupant);
-                        }
-                    });
+                    this.model.occupants.on('change:show', this.showJoinOrLeaveNotification, this);
 
 
                     this.createEmojiPicker();
                     this.createEmojiPicker();
                     this.createOccupantsView();
                     this.createOccupantsView();
@@ -1383,6 +1374,17 @@
                     }
                     }
                 },
                 },
 
 
+                showJoinOrLeaveNotification (occupant) {
+                    if (!occupant.isMember() || _.includes(occupant.get('states'), '303')) {
+                        return;
+                    }
+                    if (occupant.get('show') === 'offline') {
+                        this.showLeaveNotification(occupant);
+                    } else if (occupant.get('show') === 'online') {
+                        this.showJoinNotification(occupant);
+                    }
+                },
+
                 showJoinNotification (occupant) {
                 showJoinNotification (occupant) {
                     if (this.model.get('connection_status') !==  converse.ROOMSTATUS.ENTERED) {
                     if (this.model.get('connection_status') !==  converse.ROOMSTATUS.ENTERED) {
                         return;
                         return;