Show all contacts all the time
Contacts without conversation identity appear in alphabetical order at the end of the inbox. // FREEBIE
This commit is contained in:
		
					parent
					
						
							
								b4960b29d8
							
						
					
				
			
			
				commit
				
					
						760bfffb50
					
				
			
		
					 5 changed files with 69 additions and 18 deletions
				
			
		| 
						 | 
					@ -123,22 +123,26 @@
 | 
				
			||||||
            name: contactDetails.name,
 | 
					            name: contactDetails.name,
 | 
				
			||||||
            id: contactDetails.number,
 | 
					            id: contactDetails.number,
 | 
				
			||||||
            avatar: contactDetails.avatar,
 | 
					            avatar: contactDetails.avatar,
 | 
				
			||||||
            type: 'private'
 | 
					            type: 'private',
 | 
				
			||||||
 | 
					            active_at: Date.now()
 | 
				
			||||||
        }).save();
 | 
					        }).save();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function onGroupReceived(ev) {
 | 
					    function onGroupReceived(ev) {
 | 
				
			||||||
        var groupDetails = ev.groupDetails;
 | 
					        var groupDetails = ev.groupDetails;
 | 
				
			||||||
        var conversation = ConversationController.create({
 | 
					        var attributes = {
 | 
				
			||||||
            id: groupDetails.id,
 | 
					            id: groupDetails.id,
 | 
				
			||||||
            name: groupDetails.name,
 | 
					            name: groupDetails.name,
 | 
				
			||||||
            members: groupDetails.members,
 | 
					            members: groupDetails.members,
 | 
				
			||||||
            avatar: groupDetails.avatar,
 | 
					            avatar: groupDetails.avatar,
 | 
				
			||||||
            type: 'group',
 | 
					            type: 'group',
 | 
				
			||||||
        });
 | 
					        };
 | 
				
			||||||
        if (!groupDetails.active) {
 | 
					        if (groupDetails.active) {
 | 
				
			||||||
            conversation.set({left: true});
 | 
					            attributes.active_at = Date.now();
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            attributes.left = true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        var conversation = ConversationController.create(attributes);
 | 
				
			||||||
        conversation.save();
 | 
					        conversation.save();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,8 +17,29 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            this.listenTo(conversations, 'add change:active_at', this.addActive);
 | 
					            this.listenTo(conversations, 'add change:active_at', this.addActive);
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        comparator: function(model) {
 | 
					        comparator: function(m1, m2) {
 | 
				
			||||||
            return -model.get('timestamp');
 | 
					            var timestamp1 = m1.get('timestamp');
 | 
				
			||||||
 | 
					            var timestamp2 = m2.get('timestamp');
 | 
				
			||||||
 | 
					            if (timestamp1 && timestamp2) {
 | 
				
			||||||
 | 
					                return timestamp2 - timestamp1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (timestamp1) {
 | 
				
			||||||
 | 
					                return -1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (timestamp2) {
 | 
				
			||||||
 | 
					                return 1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            var title1 = m1.getTitle().toLowerCase();
 | 
				
			||||||
 | 
					            var title2 = m2.getTitle().toLowerCase();
 | 
				
			||||||
 | 
					            if (title1 ===  title2) {
 | 
				
			||||||
 | 
					                return 0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (title1 < title2) {
 | 
				
			||||||
 | 
					                return -1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (title1 > title2) {
 | 
				
			||||||
 | 
					                return 1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        addActive: function(model) {
 | 
					        addActive: function(model) {
 | 
				
			||||||
            if (model.get('active_at')) {
 | 
					            if (model.get('active_at')) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -144,6 +144,41 @@
 | 
				
			||||||
                conversations.createIndex('unread', ['conversationId', 'unread'], { unique: false });
 | 
					                conversations.createIndex('unread', ['conversationId', 'unread'], { unique: false });
 | 
				
			||||||
                next();
 | 
					                next();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            version: "9.0",
 | 
				
			||||||
 | 
					            migrate: function(transaction, next) {
 | 
				
			||||||
 | 
					                console.log('migration 9.0');
 | 
				
			||||||
 | 
					                window.addEventListener('storage_ready', function() {
 | 
				
			||||||
 | 
					                    console.log('marking contacts and groups active');
 | 
				
			||||||
 | 
					                    var all = new Whisper.ConversationCollection();
 | 
				
			||||||
 | 
					                    var myNumber = textsecure.storage.user.getNumber();
 | 
				
			||||||
 | 
					                    all.fetch().then(function() {
 | 
				
			||||||
 | 
					                        var inactive = all.filter(function(model) {
 | 
				
			||||||
 | 
					                            return !model.get('active_at') && model.id !== myNumber;
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					                        inactive.sort(function(m1, m2) {
 | 
				
			||||||
 | 
					                            var title1 = m1.getTitle().toLowerCase();
 | 
				
			||||||
 | 
					                            var title2 = m2.getTitle().toLowerCase();
 | 
				
			||||||
 | 
					                            if (title1 ===  title2) {
 | 
				
			||||||
 | 
					                                return 0;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (title1 < title2) {
 | 
				
			||||||
 | 
					                                return -1;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            if (title1 > title2) {
 | 
				
			||||||
 | 
					                                return 1;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					                        inactive.forEach(function(model) {
 | 
				
			||||||
 | 
					                            if (model.isPrivate() || !model.get('left')) {
 | 
				
			||||||
 | 
					                                model.save({ active_at: 1 });
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					                next();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
}());
 | 
					}());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,8 @@
 | 
				
			||||||
                if (conversation.get('active_at')) {
 | 
					                if (conversation.get('active_at')) {
 | 
				
			||||||
                    $el.prependTo(this.el);
 | 
					                    $el.prependTo(this.el);
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    $el.remove();
 | 
					                    var index = getInboxCollection().indexOf(conversation);
 | 
				
			||||||
 | 
					                    $el.insertBefore(this.$('.conversation-list-item')[index+1]);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -95,16 +95,6 @@
 | 
				
			||||||
            this.listenTo(this.searchView, 'open',
 | 
					            this.listenTo(this.searchView, 'open',
 | 
				
			||||||
                this.openConversation.bind(this, null));
 | 
					                this.openConversation.bind(this, null));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (inboxCollection.length === 0) {
 | 
					 | 
				
			||||||
                this.searchView.showAllContacts = true;
 | 
					 | 
				
			||||||
                this.searchView.reset();
 | 
					 | 
				
			||||||
                this.listenToOnce(inboxCollection, 'add', function(model) {
 | 
					 | 
				
			||||||
                    this.searchView.showAllContacts = false;
 | 
					 | 
				
			||||||
                    this.searchView.reset();
 | 
					 | 
				
			||||||
                    model.trigger('opened');
 | 
					 | 
				
			||||||
                }.bind(this));
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            new SocketView().render().$el.appendTo(this.$('.socket-status'));
 | 
					            new SocketView().render().$el.appendTo(this.$('.socket-status'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            extension.windows.onClosed(function() {
 | 
					            extension.windows.onClosed(function() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue