2024-12-10 09:36:43 +00:00
|
|
|
import 'package:hive_flutter/hive_flutter.dart';
|
|
|
|
import 'package:konectar_events/model/hive_api_constants.dart';
|
|
|
|
|
|
|
|
class HiveOperations {
|
|
|
|
static Future<void> saveApiConstants(List<HiveApiConstants> hiveList) async {
|
|
|
|
late Box<HiveApiConstants> hiveApiConstantsBox;
|
|
|
|
hiveApiConstantsBox =
|
|
|
|
await Hive.openBox<HiveApiConstants>('hiveApiConstants');
|
|
|
|
|
|
|
|
hiveApiConstantsBox.addAll(hiveList);
|
|
|
|
}
|
|
|
|
|
2024-12-16 11:26:32 +00:00
|
|
|
static Future<bool> checkIfApiExists(String api, String moduleName) async {
|
2024-12-10 09:36:43 +00:00
|
|
|
late Box<HiveApiConstants> hiveApiConstantsBox;
|
|
|
|
hiveApiConstantsBox =
|
|
|
|
await Hive.openBox<HiveApiConstants>('hiveApiConstants');
|
|
|
|
|
|
|
|
List<HiveApiConstants> list = hiveApiConstantsBox.values.toList();
|
|
|
|
return list.indexWhere(
|
2024-12-16 11:26:32 +00:00
|
|
|
(element) =>
|
|
|
|
element.functionName == api && element.module == moduleName,
|
2024-12-10 09:36:43 +00:00
|
|
|
) ==
|
|
|
|
-1
|
|
|
|
? false
|
|
|
|
: true;
|
|
|
|
}
|
|
|
|
}
|