Add functionality to edit sheets with save and restore
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user