When finding all groups involving a number, load from DB not memory
FREEBIE
This commit is contained in:
		
					parent
					
						
							
								0adc398a6f
							
						
					
				
			
			
				commit
				
					
						3e0fa995dd
					
				
			
		
					 3 changed files with 12 additions and 10 deletions
				
			
		| 
						 | 
					@ -116,8 +116,11 @@
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        getAllGroupsInvolvingId: function(id) {
 | 
					        getAllGroupsInvolvingId: function(id) {
 | 
				
			||||||
            return conversations.filter(function(conversation) {
 | 
					            var groups = new Whisper.GroupCollection();
 | 
				
			||||||
                return !conversation.isPrivate() && conversation.hasMember(id);
 | 
					            return groups.fetchGroups(id).then(function() {
 | 
				
			||||||
 | 
					                return groups.map(function(group) {
 | 
				
			||||||
 | 
					                    return conversations.add(group);
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        updateInbox: function() {
 | 
					        updateInbox: function() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,11 +17,9 @@
 | 
				
			||||||
          conversation.fetch().then(function() {
 | 
					          conversation.fetch().then(function() {
 | 
				
			||||||
            conversation.addKeyChange(id);
 | 
					            conversation.addKeyChange(id);
 | 
				
			||||||
          });
 | 
					          });
 | 
				
			||||||
          var groups = new Whisper.GroupCollection();
 | 
					          ConversationController.getAllGroupsInvolvingId(id).then(function(groups) {
 | 
				
			||||||
          return groups.fetchGroups(id).then(function() {
 | 
					            _.forEach(groups, function(group) {
 | 
				
			||||||
            groups.each(function(conversation) {
 | 
					              group.addKeyChange(id);
 | 
				
			||||||
              conversation = ConversationController.add(conversation);
 | 
					 | 
				
			||||||
              conversation.addKeyChange(id);
 | 
					 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
          });
 | 
					          });
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -320,9 +320,10 @@
 | 
				
			||||||
        message.save().then(this.trigger.bind(this,'newmessage', message));
 | 
					        message.save().then(this.trigger.bind(this,'newmessage', message));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (this.isPrivate()) {
 | 
					        if (this.isPrivate()) {
 | 
				
			||||||
            var groups = ConversationController.getAllGroupsInvolvingId(id);
 | 
					            ConversationController.getAllGroupsInvolvingId(id).then(function(groups) {
 | 
				
			||||||
            _.forEach(groups, function(group) {
 | 
					                _.forEach(groups, function(group) {
 | 
				
			||||||
                group.addVerifiedChange(id, verified, options);
 | 
					                    group.addVerifiedChange(id, verified, options);
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue