Format code

This commit is contained in:
2026-02-06 16:52:00 +01:00
parent 0fdf56c084
commit a70c634d35
2 changed files with 26 additions and 30 deletions

View File

@@ -30,19 +30,19 @@ class Change {
/// Serializes this change to a map for storage.
Map<String, dynamic> toMap() => {
'type': type.index,
'sheetUuid': sheetUuid,
'value': value,
'createdAt': createdAt.toIso8601String(),
};
'type': type.index,
'sheetUuid': sheetUuid,
'value': value,
'createdAt': createdAt.toIso8601String(),
};
/// Serializes this change to JSON for API requests.
Map<String, dynamic> toJson() => {
'type': type.name,
'sheetUuid': sheetUuid,
'value': value,
'createdAt': createdAt.toIso8601String(),
};
'type': type.name,
'sheetUuid': sheetUuid,
'value': value,
'createdAt': createdAt.toIso8601String(),
};
/// Deserializes a change from a stored map.
///
@@ -91,9 +91,8 @@ class ChangeQueue {
for (final change in _queue) {
final sheet = sheets.firstWhere(
(s) => s.uuid == change.sheetUuid,
orElse: () => throw StateError(
'Sheet with UUID ${change.sheetUuid} not found',
),
orElse: () =>
throw StateError('Sheet with UUID ${change.sheetUuid} not found'),
);
switch (change.type) {

View File

@@ -14,15 +14,12 @@ class StoredAnnotation {
final String annotationsJson;
final DateTime lastModified;
StoredAnnotation({
required this.annotationsJson,
required this.lastModified,
});
StoredAnnotation({required this.annotationsJson, required this.lastModified});
Map<String, dynamic> toMap() => {
'annotationsJson': annotationsJson,
'lastModified': lastModified.toIso8601String(),
};
'annotationsJson': annotationsJson,
'lastModified': lastModified.toIso8601String(),
};
factory StoredAnnotation.fromMap(Map<dynamic, dynamic> map) {
return StoredAnnotation(
@@ -52,11 +49,11 @@ class PendingAnnotationUpload {
});
Map<String, dynamic> toMap() => {
'sheetUuid': sheetUuid,
'page': page,
'annotationsJson': annotationsJson,
'lastModified': lastModified.toIso8601String(),
};
'sheetUuid': sheetUuid,
'page': page,
'annotationsJson': annotationsJson,
'lastModified': lastModified.toIso8601String(),
};
factory PendingAnnotationUpload.fromMap(Map<dynamic, dynamic> map) {
return PendingAnnotationUpload(
@@ -142,9 +139,8 @@ class StorageService {
Future<Map<String, DateTime>> readSheetAccessTimes() async {
final box = await Hive.openBox(_sheetAccessTimesBox);
return box.toMap().map(
(key, value) =>
MapEntry(key as String, DateTime.parse(value as String)),
);
(key, value) => MapEntry(key as String, DateTime.parse(value as String)),
);
}
/// Records when a sheet was last accessed.
@@ -308,8 +304,9 @@ class StorageService {
Future<void> deleteAllAnnotations(String sheetUuid) async {
final box = await Hive.openBox(_annotationsBox);
final prefix = '${sheetUuid}_page_';
final keysToDelete =
box.keys.where((key) => key is String && key.startsWith(prefix));
final keysToDelete = box.keys.where(
(key) => key is String && key.startsWith(prefix),
);
for (final key in keysToDelete.toList()) {
await box.delete(key);