Skip to content

Commit

Permalink
Debounced tables filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasp authored and Paxa committed Jun 3, 2021
1 parent 2164c8f commit cae0242
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,13 @@ $u.textareaAutoSize = function (element) {
element.style.height = 'auto';
element.style.height = element.scrollHeight + 'px';
};

$u.debounce = (func, delay) => {
let inDebounce;
return function () {
const context = this;
const args = arguments;
clearTimeout(inDebounce);
inDebounce = setTimeout(() => func.apply(context, args), delay);
};
};
3 changes: 2 additions & 1 deletion app/views/db_screen_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class DbScreenView {
this.sidebar.find('a.addTable').bind('click', this.newTableDialog.bind(this));
this.sidebar.find('a.reloadStructure').bind('click', this.reloadStructure.bind(this));

this.sidebar.find('input.filter-tables').bind('keyup', this.filterTables.bind(this));
this.sidebar.find('input.filter-tables')
.bind('keyup', $u.debounce(this.filterTables, 500).bind(this));
this.sidebar.find('span.clear-filter').bind('click', () => {
this.clearTablesFilter();
})
Expand Down

0 comments on commit cae0242

Please sign in to comment.