Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2023-08-29 22:00:52 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2023-08-29 22:00:52 +0300
commit6aeedac051dde1c0fb6db23cd6ab83a6ff26fb7c (patch)
tree441c31eeb57fe9814ba58fda09a27b39f14d0de2
parent9c231a41d1fbdb296f7efde63e76fd8d91bdebcf (diff)
optimized finding client index
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
-rw-r--r--web/html/xui/inbounds.html14
1 files changed, 9 insertions, 5 deletions
diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html
index 7e438f91..4e1873f8 100644
--- a/web/html/xui/inbounds.html
+++ b/web/html/xui/inbounds.html
@@ -711,7 +711,7 @@
openEditClient(dbInboundId, client) {
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
clients = this.getInboundClients(dbInbound);
- index = this.findIndexOfClient(clients, client);
+ index = this.findIndexOfClient(dbInbound.protocol, clients, client);
clientModal.show({
title: '{{ i18n "pages.client.edit"}}',
okText: '{{ i18n "pages.client.submitEdit"}}',
@@ -725,8 +725,13 @@
isEdit: true
});
},
- findIndexOfClient(clients, client) {
- return clients.findIndex(item => JSON.stringify(item) === JSON.stringify(client));
+ findIndexOfClient(protocol, clients, client) {
+ switch (protocol) {
+ case Protocols.TROJAN:
+ case Protocols.SHADOWSOCKS:
+ return clients.findIndex(item => item.password === client.password && item.email === client.email);
+ default: return clients.findIndex(item => item.id === client.id && item.email === client.email);
+ }
},
async addClient(clients, dbInboundId) {
const data = {
@@ -832,8 +837,7 @@
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
inbound = dbInbound.toInbound();
clients = this.getClients(dbInbound.protocol, inbound.settings);
- client.enable = !client.enable; // For finding correct index in findIndexOfClient() function
- index = this.findIndexOfClient(clients, client);
+ index = this.findIndexOfClient(dbInbound.protocol, clients, client);
clients[index].enable = !clients[index].enable;
clientId = this.getClientId(dbInbound.protocol, clients[index]);
await this.updateClient(clients[index], dbInboundId, clientId);