fix: update logins even if null

This commit is contained in:
Louis-Marie Baer 2025-01-13 20:35:24 +01:00
parent 1137b50b8a
commit 130895a449
4 changed files with 30 additions and 10 deletions

View file

@ -65,12 +65,12 @@ class NodeModel {
int? port,
String? name,
bool? useSSL,
String? loginName,
required String? loginName,
bool? enabled,
String? coinName,
bool? isFailover,
bool? isDown,
bool? trusted,
required bool? trusted,
bool? torEnabled,
bool? clearnetEnabled,
}) {
@ -80,12 +80,12 @@ class NodeModel {
name: name ?? this.name,
id: id,
useSSL: useSSL ?? this.useSSL,
loginName: loginName ?? this.loginName,
loginName: loginName,
enabled: enabled ?? this.enabled,
coinName: coinName ?? this.coinName,
isFailover: isFailover ?? this.isFailover,
isDown: isDown ?? this.isDown,
trusted: trusted ?? this.trusted,
trusted: trusted,
torEnabled: torEnabled ?? this.torEnabled,
clearnetEnabled: clearnetEnabled ?? this.clearnetEnabled,
);

View file

@ -860,8 +860,10 @@ class _NodeFormState extends ConsumerState<NodeForm> {
onChanged?.call(canSave, canTestConnection);
ref.read(nodeFormDataProvider).name = _nameController.text;
ref.read(nodeFormDataProvider).host = _hostController.text;
ref.read(nodeFormDataProvider).login = _usernameController.text;
ref.read(nodeFormDataProvider).password = _passwordController.text;
ref.read(nodeFormDataProvider).login =
_usernameController.text.isEmpty ? null : _usernameController.text;
ref.read(nodeFormDataProvider).password =
_passwordController.text.isEmpty ? null : _passwordController.text;
ref.read(nodeFormDataProvider).port = port;
ref.read(nodeFormDataProvider).useSSL = _useSSL;
ref.read(nodeFormDataProvider).isFailover = _isFailover;
@ -1326,7 +1328,11 @@ class _NodeFormState extends ConsumerState<NodeForm> {
});
if (widget.readOnly) {
ref.read(nodeServiceChangeNotifierProvider).edit(
widget.node!.copyWith(isFailover: _isFailover),
widget.node!.copyWith(
isFailover: _isFailover,
loginName: widget.node!.loginName,
trusted: widget.node!.trusted,
),
null,
true,
);
@ -1351,8 +1357,11 @@ class _NodeFormState extends ConsumerState<NodeForm> {
});
if (widget.readOnly) {
ref.read(nodeServiceChangeNotifierProvider).edit(
widget.node!
.copyWith(isFailover: _isFailover),
widget.node!.copyWith(
isFailover: _isFailover,
loginName: widget.node!.loginName,
trusted: widget.node!.trusted,
),
null,
true,
);

View file

@ -1071,6 +1071,7 @@ abstract class SWB {
loginName: nodeData['loginName'] as String?,
isFailover: nodeData['isFailover'] as bool,
isDown: nodeData['isDown'] as bool,
trusted: nodeData['trusted'] as bool?,
),
nodeData['password'] as String?,
true,

View file

@ -104,6 +104,7 @@ class NodeService extends ChangeNotifier {
trusted: savedNode.trusted,
torEnabled: savedNode.torEnabled,
clearnetEnabled: savedNode.clearnetEnabled,
loginName: savedNode.loginName,
),
);
}
@ -122,6 +123,7 @@ class NodeService extends ChangeNotifier {
trusted: primaryNode.trusted,
torEnabled: primaryNode.torEnabled,
clearnetEnabled: primaryNode.clearnetEnabled,
loginName: primaryNode.loginName,
),
);
}
@ -213,6 +215,8 @@ class NodeService extends ChangeNotifier {
key: "${node.id}_nodePW",
value: password,
);
} else {
await secureStorageInterface.delete(key: "${node.id}_nodePW");
}
if (shouldNotifyListeners) {
notifyListeners();
@ -240,7 +244,11 @@ class NodeService extends ChangeNotifier {
await DB.instance.put<NodeModel>(
boxName: DB.boxNameNodeModels,
key: model.id,
value: model.copyWith(enabled: enabled),
value: model.copyWith(
enabled: enabled,
loginName: model.loginName,
trusted: model.trusted,
),
);
if (shouldNotifyListeners) {
notifyListeners();
@ -314,6 +322,8 @@ class NodeService extends ChangeNotifier {
useSSL: node.useSSL,
coinName: node.coinName,
isDown: node.isDown,
loginName: node.loginName,
trusted: node.trusted,
);
}
await add(node, null, false);