fix mount settings encrypt
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2025-03-20 20:53:36 -05:00
parent a28151068a
commit 164f8ffc7c
4 changed files with 37 additions and 12 deletions

View File

@ -107,6 +107,17 @@ Map<String, dynamic> createDefaultSettings(String mountType) {
return {};
}
void displayAuthError() {
if (constants.navigatorKey.currentContext == null) {
return;
}
displayErrorMessage(
constants.navigatorKey.currentContext!,
"Authentication failed",
);
}
void displayErrorMessage(context, String text) {
if (!context.mounted) {
return;

View File

@ -180,6 +180,11 @@ class Mount with ChangeNotifier {
return;
}
if (response.statusCode == 500) {
displayAuthError();
return;
}
if (response.statusCode != 200) {
return;
}

View File

@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:repertory/constants.dart' as constants;
import 'package:repertory/helpers.dart'
show getSettingDescription, getSettingValidators;
show convertAllToString, getSettingDescription, getSettingValidators;
import 'package:repertory/models/mount.dart';
import 'package:repertory/models/mount_list.dart';
import 'package:repertory/settings.dart';
@ -615,24 +615,41 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
void dispose() {
if (!widget.isAdd) {
var settings = widget.mount.mountConfig.settings;
Map<String, dynamic> changedSettings = {};
if (!DeepCollectionEquality().equals(widget.settings, settings)) {
widget.settings.forEach((key, value) {
if (!DeepCollectionEquality().equals(settings[key], value)) {
if (value is Map<String, dynamic>) {
changedSettings[key] = <String, dynamic>{};
value.forEach((subKey, subValue) {
if (!DeepCollectionEquality().equals(
settings[key][subKey],
subValue,
)) {
widget.mount.setValue('$key.$subKey', subValue.toString());
changedSettings[key][subKey] = subValue;
}
});
} else {
widget.mount.setValue(key, value.toString());
changedSettings[key] = value;
}
}
});
}
if (changedSettings.isNotEmpty) {
convertAllToString(changedSettings).then((map) {
map.forEach((key, value) {
if (value is Map<String, dynamic>) {
value.forEach((subKey, subValue) {
widget.mount.setValue('$key.$subKey', subValue);
});
return;
}
widget.mount.setValue(key, value);
});
});
}
}
super.dispose();

View File

@ -8,6 +8,7 @@ import 'package:repertory/helpers.dart'
show
AuthenticationFailedException,
convertAllToString,
displayAuthError,
displayErrorMessage,
getBaseUri,
getSettingDescription,
@ -107,15 +108,6 @@ class _UISettingsWidgetState extends State<UISettingsWidget> {
widget.settings,
widget.origSettings,
)) {
displayAuthError() {
if (constants.navigatorKey.currentContext != null) {
displayErrorMessage(
constants.navigatorKey.currentContext!,
"Authentication failed",
);
}
}
convertAllToString(widget.settings)
.then((map) async {
try {