[polari/wip/kunaljain/polari-search-result-view] peformance improvements
- From: Kunal Jain <kunaljain src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/kunaljain/polari-search-result-view] peformance improvements
- Date: Thu, 21 Jul 2016 11:00:43 +0000 (UTC)
commit 9344e4406aaca273ee961b37fcc4fa25c0fd8023
Author: Kunaal Jain <kunaalus gmail com>
Date: Thu Jul 21 16:29:49 2016 +0530
peformance improvements
src/mainWindow.js | 9 +++------
src/resultList.js | 18 +++++++++++++-----
2 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 9bc27a3..238f019 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -483,18 +483,15 @@ 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 8832b48..c6d11b1 100644
--- a/src/resultList.js
+++ b/src/resultList.js
@@ -11,6 +11,8 @@ const AccountsMonitor = imports.accountsMonitor;
const ChatroomManager = imports.chatroomManager;
const Lang = imports.lang;
+const MIN_SEARCH_WIDTH = 4;
+
const ResultRow = new Lang.Class({
Name: 'ResultRow',
Extends: Gtk.ListBoxRow,
@@ -180,17 +182,21 @@ const ResultList = new Lang.Class({
},
_clearList: function() {
- this.foreach(r => { r.destroy(); });
+ this.foreach(r => { r.hide(); });
+ },
+
+ _showList: function() {
+ this.foreach(r => { r.show(); });
},
_handleSearchChanged: function(group, actionName, value) {
this._cancellable.cancel();
- this._cancellable.reset();
-
+ // this._cancellable.reset();
+ this._cancellable = new Gio.Cancellable();
let text = value.deep_unpack();
+ this._clearList();
- if(text == '') {
- this._clearList();
+ if(text.length < MIN_SEARCH_WIDTH) {
return;
}
@@ -242,6 +248,8 @@ const ResultList = new Lang.Class({
let row = this._widgetMap[events[i].id];
this.add(row);
}
+
+ this._showList();
},
_formatTimestamp: function(timestamp) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]