Change mapping

This commit is contained in:
problematicconsumer
2024-02-17 11:58:34 +03:30
parent 0aeb0e346f
commit 3541f8e3db
9 changed files with 269 additions and 364 deletions

View File

@@ -34,7 +34,7 @@ class ConfigOptionRepositoryImpl
@override
Either<ConfigOptionFailure, ConfigOptionEntity> getConfigOption() {
try {
final map = ConfigOptionEntity.initial().toMap();
final map = ConfigOptionEntity.initial().toJson();
for (final key in map.keys) {
final persisted = preferences.get(key);
if (persisted != null) {
@@ -49,7 +49,7 @@ class ConfigOptionRepositoryImpl
map[key] = persisted;
}
}
final options = ConfigOptionEntityMapper.fromMap(map);
final options = ConfigOptionEntity.fromJson(map);
return right(options);
} catch (error, stackTrace) {
return left(ConfigOptionUnexpectedFailure(error, stackTrace));
@@ -62,7 +62,7 @@ class ConfigOptionRepositoryImpl
) {
return exceptionHandler(
() async {
final map = patch.toMap();
final map = patch.toJson();
await updateByJson(map);
return right(unit);
},
@@ -74,7 +74,7 @@ class ConfigOptionRepositoryImpl
TaskEither<ConfigOptionFailure, Unit> resetConfigOption() {
return exceptionHandler(
() async {
final map = ConfigOptionEntity.initial().toMap();
final map = ConfigOptionEntity.initial().toJson();
await updateByJson(map);
return right(unit);
},
@@ -86,7 +86,7 @@ class ConfigOptionRepositoryImpl
Future<void> updateByJson(
Map<String, dynamic> options,
) async {
final map = ConfigOptionEntity.initial().toMap();
final map = ConfigOptionEntity.initial().toJson();
for (final key in map.keys) {
final value = options[key];
if (value != null) {