Add functionality to edit sheets with save and restore

This commit is contained in:
2025-11-15 22:26:33 +01:00
parent 31ecd3c820
commit 3edc3229e9
5 changed files with 202 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:hive/hive.dart';
import 'package:sheetless/upload_queue.dart';
enum SecureStorageKey { url, jwt, email }
@@ -18,6 +19,7 @@ class Config {
class StorageHelper {
final sheetAccessTimesBox = "sheetAccessTimes";
final configBox = "config";
final changeQueueBox = "changeQueue";
late FlutterSecureStorage secureStorage;
@@ -60,4 +62,23 @@ class StorageHelper {
final box = await Hive.openBox(sheetAccessTimesBox);
await box.put(uuid, datetime.toIso8601String());
}
Future<void> writeChange(Change change) async {
final box = await Hive.openBox(changeQueueBox);
box.add(change.toMap());
}
Future<ChangeQueue> readChangeQueue() async {
final box = await Hive.openBox(changeQueueBox);
ChangeQueue queue = ChangeQueue();
for (Map<dynamic, dynamic> map in box.values) {
queue.addChange(Change.fromMap(map));
}
return queue;
}
Future<void> deleteOldestChange(Change change) async {
final box = await Hive.openBox(changeQueueBox);
box.deleteAt(0);
}
}