<commit_before>/*
 * vim: ts=4:sw=4:expandtab
 */
(function () {
    'use strict';
    window.Whisper = window.Whisper || {};

    Whisper.ConversationSearchView = Whisper.View.extend({
        className: 'conversation-search',
        initialize: function(options) {
            this.$input = options.input;
            this.$new_contact = this.$('.new-contact');

            this.typeahead = new Whisper.ConversationCollection();
            // View to display the matched contacts from typeahead
            this.typeahead_view = new Whisper.ConversationListView({
                collection : new Whisper.ConversationCollection([], {
                    comparator: function(m) { return m.getTitle().toLowerCase(); }
                })
            });
            this.$el.append(this.typeahead_view.el);
            this.initNewContact();
            //this.listenTo(this.collection, 'reset', this.filterContacts);

        },

        events: {
            'select .new-contact': 'createConversation',
            'select .contacts': 'open'
        },

        filterContacts: function(e) {
            var query = this.$input.val();
            if (query.length) {
                if (this.maybeNumber(query)) {
                    this.new_contact_view.model.set('id', query);
                    this.new_contact_view.render().$el.show();
                } else {
                    this.new_contact_view.$el.hide();
                }
                this.typeahead.search(query).then(function() {
                    this.typeahead_view.collection.reset(this.typeahead.models);
                }.bind(this));<commit_msg>Serialize search queries<commit_after>/*
 * vim: ts=4:sw=4:expandtab
 */
(function () {
    'use strict';
    window.Whisper = window.Whisper || {};

    Whisper.ConversationSearchView = Whisper.View.extend({
        className: 'conversation-search',
        initialize: function(options) {
            this.$input = options.input;
            this.$new_contact = this.$('.new-contact');

            this.typeahead = new Whisper.ConversationCollection();
            // View to display the matched contacts from typeahead
            this.typeahead_view = new Whisper.ConversationListView({
                collection : new Whisper.ConversationCollection([], {
                    comparator: function(m) { return m.getTitle().toLowerCase(); }
                })
            });
            this.$el.append(this.typeahead_view.el);
            this.initNewContact();
            //this.listenTo(this.collection, 'reset', this.filterContacts);
            this.pending = Promise.resolve();
        },

        events: {
            'select .new-contact': 'createConversation',
            'select .contacts': 'open'
        },

        filterContacts: function(e) {
            var query = this.$input.val();
            if (query.length) {
                if (this.maybeNumber(query)) {
                    this.new_contact_view.model.set('id', query);
                    this.new_contact_view.render().$el.show();
                } else {
                    this.new_contact_view.$el.hide();
                }
                this.pending = this.pending.then(function() {
                    return this.typeahead.search(query).then(function() {
                        this.typeahead_view.collection.reset(this.typeahead.models);
                    }.bind(this));
                }.bind(this));
{'fraction_non_alphanumeric': 0.13053613053613053, 'fraction_numerical': 0.0011655011655011655, 'mean_word_length': 1.7311058074781225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4024124', 'n_tokens_mistral': 942, 'n_tokens_neox': 894, 'n_words': 143}