opt: support match user/hostname/id(sciter), case insensitive

Signed-off-by: Kingtous <kingtous@qq.com>
This commit is contained in:
Kingtous 2022-08-27 01:03:20 +08:00
parent ff5e9a8ea5
commit 4e047f1bb2
2 changed files with 10 additions and 4 deletions

View File

@ -725,6 +725,7 @@ Future<bool> matchPeer(String searchText, Peer peer) async {
}
Future<List<Peer>>? matchPeers(String searchText, List<Peer> peers) async {
searchText = searchText.trim();
if (searchText.isEmpty) {
return peers;
}
@ -738,4 +739,4 @@ Future<List<Peer>>? matchPeers(String searchText, List<Peer> peers) async {
}
}
return filteredList;
}
}

View File

@ -245,7 +245,7 @@ class SearchBar: Reactor.Component {
}
event change $(input) (_, el) {
this.onChange(el.value.trim());
this.onChange(el.value.trim().toLowerCase());
}
function onChange(v) {
@ -297,8 +297,13 @@ class SessionList: Reactor.Component {
if (!p) return this.sessions;
var tmp = [];
this.sessions.map(function(s) {
var name = s[4] || s.alias || s[0] || s.id || "";
if (name.indexOf(p) >= 0) tmp.push(s);
var name = (s[4] || s.alias || "").toLowerCase();
var id = (s[0] || s.id || "").toLowerCase();
var user = (s[1] || "").toLowerCase();
var hostname = (s[2] || "").toLowerCase();
if (name.indexOf(p) >= 0 || id.indexOf(p) >= 0 || user.indexOf(p) >= 0 || hostname.indexOf(p) >= 0) {
tmp.push(s);
}
});
return tmp;
}