Fixed client being added to two lists

This commit is contained in:
Juan Gilsanz Polo 2022-09-29 23:27:29 +02:00
parent 4bb24b98b5
commit 6401dc5367
5 changed files with 29 additions and 3 deletions

View file

@ -93,5 +93,7 @@
"ipAddress": "IP address",
"ipNotValid": "IP address not valid",
"clientAddedSuccessfully": "Client added to the list successfully",
"addingClient": "Adding client..."
"addingClient": "Adding client...",
"clientNotAdded": "Client could not be added to the list",
"clientAnotherList": "This client is yet in another list"
}

View file

@ -93,5 +93,7 @@
"ipAddress": "Dirección IP",
"ipNotValid": "Dirección IP no válida",
"clientAddedSuccessfully": "Cliente añadido a la lista satisfactoriamente",
"addingClient": "Añadiendo cliente..."
"addingClient": "Añadiendo cliente...",
"clientNotAdded": "El cliente no se pudo añadir a la lista",
"clientAnotherList": "El cliente ya está en otra lista"
}

View file

@ -59,6 +59,14 @@ class BlockedAllowedList extends StatelessWidget {
)
);
}
else if (result['result'] == 'error' && result['message'] == 'client_another_list') {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(AppLocalizations.of(context)!.clientAnotherList),
backgroundColor: Colors.red,
)
);
}
else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(

View file

@ -62,10 +62,18 @@ class ClientsFab extends StatelessWidget {
)
);
}
else if (result['result'] == 'error' && result['message'] == 'client_another_list') {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(AppLocalizations.of(context)!.clientAnotherList),
backgroundColor: Colors.red,
)
);
}
else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(AppLocalizations.of(context)!.clientNotRemoved),
content: Text(AppLocalizations.of(context)!.clientNotAdded),
backgroundColor: Colors.red,
)
);

View file

@ -285,6 +285,12 @@ Future requestAllowedBlockedClientsHosts(Server server, Map<String, List<String>
if (result.statusCode == 200) {
return {'result': 'success'};
}
else if (result.statusCode == 400) {
return {
'result': 'error',
'message': 'client_another_list'
};
}
else {
return {'result': 'error'};
}