[polari/wip/fmuellner/combined-gsoc: 41/137] limit search results



commit 9ca5b88488773949087625c13c54bb8ca5f6e87f
Author: Kunaal Jain <kunaalus gmail com>
Date:   Thu Jul 21 15:58:30 2016 +0530

    limit search results

 src/mainWindow.js |   10 +++++++---
 src/resultList.js |    6 ++++--
 2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 48c3a14..3c791fa 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -25,6 +25,7 @@ const ResultStack = imports.resultStack;
 
 const CONFIGURE_TIMEOUT = 100; /* ms */
 
+const MIN_SEARCH_WIDTH = 4;
 
 const FixedSizeFrame = new Lang.Class({
     Name: 'FixedSizeFrame',
@@ -479,15 +480,18 @@ const MainWindow = new Lang.Class({
 
     _handleSearchChanged: function(entry) {
         let text = entry.get_text().replace(/^\s+|\s+$/g, '');
-        let app = this.application;
-        let action = app.lookup_action('search-terms');
-        action.change_state(GLib.Variant.new('s', text));
         if(text!='') {
             this._mode='search';
         } else {
             this._mode='chat';
         }
         this.notify('mode');
+        if (text.length < MIN_SEARCH_WIDTH) {
+            return;
+        }
+        let app = this.application;
+        let action = app.lookup_action('search-terms');
+        action.change_state(GLib.Variant.new('s', text));
         return;
         this._cancellable.cancel();
         this._cancellable.reset();
diff --git a/src/resultList.js b/src/resultList.js
index 262d793..8832b48 100644
--- a/src/resultList.js
+++ b/src/resultList.js
@@ -200,10 +200,12 @@ const ResultList = new Lang.Class({
         let query = ('select ?text as ?mms ?msg as ?id ?chan as ?chan ?timestamp as ?timestamp ' +
                       'where { ?msg a nmo:IMMessage . ?msg nie:plainTextContent ?text . ?msg fts:match "%s*" 
. ' +
                       '?msg nmo:communicationChannel ?channel. ?channel nie:title ?chan. ' +
-                      '?msg nie:contentCreated ?timestamp }'
+                      '?msg nie:contentCreated ?timestamp } order by desc (?timestamp)'
                      ).format(text);
         log(query);
-        this._logManager.query(query,this._cancellable,Lang.bind(this, this._handleResults));
+        this._endQuery = new LogManager.GenericQuery(this._logManager._connection, 20);
+        this._endQuery.run(query,this._cancellable,Lang.bind(this, this._handleResults));
+        // this._logManager.query(query,this._cancellable,Lang.bind(this, this._handleResults));
     },
 
     _handleResults: function(events) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]