From f8ca748ab84ed267aef9a95da5bc709da96af3cd Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Fri, 23 Sep 2011 03:48:21 -0400 Subject: [PATCH] - Fix check if new search value contains old one and previous search was empty in autocomplete --- program/js/app.js | 44 ++++++++++++++++++++++++++++---------------- 1 files changed, 28 insertions(+), 16 deletions(-) diff --git a/program/js/app.js b/program/js/app.js index 65d4f06..40aa76f 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -278,6 +278,9 @@ if (this.gui_objects.folderlist) this.env.contactfolders = $.extend($.extend({}, this.env.address_sources), this.env.contactgroups); + this.enable_command('add', 'import', this.env.writable_source); + this.enable_command('list', 'listgroup', 'listsearch', 'advanced-search', true); + if (this.gui_objects.contactslist) { this.contact_list = new rcube_list_widget(this.gui_objects.contactslist, @@ -300,6 +303,7 @@ } this.update_group_commands(); + this.command('list'); } this.set_page_buttons(); @@ -319,21 +323,12 @@ if (this.env.action == 'add' || this.env.action == 'edit') this.init_contact_form(); } + if (this.gui_objects.qsearchbox) { this.enable_command('search', 'reset-search', 'moveto', true); } - if (this.contact_list && this.contact_list.rowcount > 0) - this.enable_command('export', true); - - this.enable_command('add', 'import', this.env.writable_source); - this.enable_command('list', 'listgroup', 'listsearch', 'advanced-search', true); - - // load contacts of selected source - if (!this.env.action) - this.command('list', this.env.source); break; - case 'settings': this.enable_command('preferences', 'identities', 'save', 'folders', true); @@ -847,6 +842,8 @@ break; } + else if (props) + url += '&_to='+urlencode(props); this.redirect(url); break; @@ -1641,6 +1638,10 @@ if (!this.gui_objects.messagelist || !this.message_list) return false; + // Prevent from adding messages from different folder (#1487752) + if (flags.mbox != this.env.mailbox && !flags.skip_mbox_check) + return false; + if (!this.env.messages[uid]) this.env.messages[uid] = {}; @@ -2091,8 +2092,12 @@ }; // Initializes threads indicators/expanders after list update - this.init_threads = function(roots) + this.init_threads = function(roots, mbox) { + // #1487752 + if (mbox && mbox != this.env.mailbox) + return false; + for (var n=0, len=roots.length; n<len; n++) this.add_tree_icons(roots[n]); this.expand_threads(); @@ -3610,7 +3615,8 @@ var cpos = this.get_caret_pos(this.ksearch_input), p = inp_value.lastIndexOf(',', cpos-1), q = inp_value.substring(p+1, cpos), - min = this.env.autocomplete_min_length; + min = this.env.autocomplete_min_length, + ac = this.ksearch_data; // trim query string q = $.trim(q); @@ -3636,8 +3642,8 @@ if (!q.length) return; - // ...new search value contains old one and previous search result was empty - if (old_value && old_value.length && this.env.contacts && !this.env.contacts.length && q.indexOf(old_value) == 0) + // ...new search value contains old one and previous search was not finished or its result was empty + if (old_value && old_value.length && q.indexOf(old_value) == 0 && (!ac || !ac.num) && this.env.contacts && !this.env.contacts.length) return; var i, lock, source, xhr, reqid = new Date().getTime(), @@ -3645,7 +3651,8 @@ sources = props && props.sources ? props.sources : [], action = props && props.action ? props.action : 'mail/autocomplete'; - this.ksearch_data = {id: reqid, sources: sources.slice(), action: action, locks: [], requests: []}; + this.ksearch_data = {id: reqid, sources: sources.slice(), action: action, + locks: [], requests: [], num: sources.length}; for (i=0; i<threads; i++) { source = this.ksearch_data.sources.shift(); @@ -3730,6 +3737,7 @@ // run next parallel search if (data.id == reqid) { + data.num--; if (maxlen > 0 && data.sources.length) { var lock, xhr, source = data.sources.shift(); if (source) { @@ -5463,8 +5471,12 @@ }; // replace content of row count display - this.set_rowcount = function(text) + this.set_rowcount = function(text, mbox) { + // #1487752 + if (mbox && mbox != this.env.mailbox) + return false; + $(this.gui_objects.countdisplay).html(text); // update page navigation buttons -- Gitblit v1.9.1