Skip to content

Commit

Permalink
Teambuilder: Debounce searching teams
Browse files Browse the repository at this point in the history
  • Loading branch information
PartMan7 committed Jul 27, 2024
1 parent d3bd677 commit 77ba9d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions data/pokemon-showdown
Submodule pokemon-showdown added at 56a517
17 changes: 14 additions & 3 deletions play.pokemonshowdown.com/js/client-teambuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
curFolder: '',
curFolderKeep: '',
curSearchVal: '',
// Debounce value for searching in the teambuilder
searchTimeout: null,

exportMode: false,
formatResources: {},
Expand Down Expand Up @@ -3239,11 +3241,20 @@
this.chartSet(val, selectNext);
},
searchChange: function (e) {
// 91 for right CMD / 93 for left CMD / 17 for CTL
if (e.keyCode !== 91 && e.keyCode !== 93 && e.keyCode !== 17) {
this.curSearchVal = e.currentTarget.value;
if (this.searchTimeout) clearTimeout(this.searchTimeout);

var searchVal = e.currentTarget.value;

function updateTeamList() {
// 91 for right CMD / 93 for left CMD / 17 for CTL
if (e.keyCode !== 91 && e.keyCode !== 93 && e.keyCode !== 17) {
this.curSearchVal = searchVal;
}
this.updateTeamList();
}
// Debounced to ensure this isn't called too frequently while typing
this.searchTimeout = setTimeout(updateTeamList.bind(this), 400);

Check failure on line 3257 in play.pokemonshowdown.com/js/client-teambuilder.js

View workflow job for this annotation

GitHub Actions / build (14.x)

Trailing spaces not allowed
},
chartSetCustom: function (val) {
val = toID(val);
Expand Down

0 comments on commit 77ba9d9

Please sign in to comment.