mirror of
https://github.com/foss42/apidash.git
synced 2025-06-01 23:45:19 +08:00
Users can now choose whether or not to save response results
This commit is contained in:
@ -139,7 +139,7 @@ class RequestModel {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> toJson({bool includeResponse = true}) {
|
||||
return {
|
||||
"id": id,
|
||||
"method": method.name,
|
||||
@ -150,9 +150,9 @@ class RequestModel {
|
||||
"requestParams": rowsToMap(requestParams),
|
||||
"requestBodyContentType": requestBodyContentType.name,
|
||||
"requestBody": requestBody,
|
||||
"responseStatus": responseStatus,
|
||||
"message": message,
|
||||
"responseModel": responseModel?.toJson(),
|
||||
"responseStatus": includeResponse ? responseStatus : null,
|
||||
"message": includeResponse ? message : null,
|
||||
"responseModel": includeResponse ? responseModel?.toJson() : null,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -188,10 +188,15 @@ class CollectionStateNotifier extends StateNotifier<List<RequestModel>?> {
|
||||
}
|
||||
|
||||
Future<void> saveData() async {
|
||||
final saveResponse =
|
||||
ref.read(settingsProvider.select((value) => value.saveResponses));
|
||||
final ids = getIds();
|
||||
await hiveHandler.setIds(ids);
|
||||
for (var e in state!) {
|
||||
await hiveHandler.setRequestModel(e.id, e.toJson());
|
||||
await hiveHandler.setRequestModel(
|
||||
e.id,
|
||||
e.toJson(includeResponse: saveResponse),
|
||||
);
|
||||
}
|
||||
await hiveHandler.removeUnused();
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
|
||||
CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: const Text("Save Responses"),
|
||||
subtitle: const Text(
|
||||
"Saves disk space & clears all previous responses on App start"),
|
||||
subtitle:
|
||||
const Text("Save disk space by not storing API responses"),
|
||||
value: settings.saveResponses,
|
||||
onChanged: (value) {
|
||||
ref
|
||||
|
Reference in New Issue
Block a user