Format code
This commit is contained in:
@@ -30,19 +30,19 @@ class Change {
|
|||||||
|
|
||||||
/// Serializes this change to a map for storage.
|
/// Serializes this change to a map for storage.
|
||||||
Map<String, dynamic> toMap() => {
|
Map<String, dynamic> toMap() => {
|
||||||
'type': type.index,
|
'type': type.index,
|
||||||
'sheetUuid': sheetUuid,
|
'sheetUuid': sheetUuid,
|
||||||
'value': value,
|
'value': value,
|
||||||
'createdAt': createdAt.toIso8601String(),
|
'createdAt': createdAt.toIso8601String(),
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Serializes this change to JSON for API requests.
|
/// Serializes this change to JSON for API requests.
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
'type': type.name,
|
'type': type.name,
|
||||||
'sheetUuid': sheetUuid,
|
'sheetUuid': sheetUuid,
|
||||||
'value': value,
|
'value': value,
|
||||||
'createdAt': createdAt.toIso8601String(),
|
'createdAt': createdAt.toIso8601String(),
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Deserializes a change from a stored map.
|
/// Deserializes a change from a stored map.
|
||||||
///
|
///
|
||||||
@@ -91,9 +91,8 @@ class ChangeQueue {
|
|||||||
for (final change in _queue) {
|
for (final change in _queue) {
|
||||||
final sheet = sheets.firstWhere(
|
final sheet = sheets.firstWhere(
|
||||||
(s) => s.uuid == change.sheetUuid,
|
(s) => s.uuid == change.sheetUuid,
|
||||||
orElse: () => throw StateError(
|
orElse: () =>
|
||||||
'Sheet with UUID ${change.sheetUuid} not found',
|
throw StateError('Sheet with UUID ${change.sheetUuid} not found'),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
switch (change.type) {
|
switch (change.type) {
|
||||||
|
|||||||
@@ -14,15 +14,12 @@ class StoredAnnotation {
|
|||||||
final String annotationsJson;
|
final String annotationsJson;
|
||||||
final DateTime lastModified;
|
final DateTime lastModified;
|
||||||
|
|
||||||
StoredAnnotation({
|
StoredAnnotation({required this.annotationsJson, required this.lastModified});
|
||||||
required this.annotationsJson,
|
|
||||||
required this.lastModified,
|
|
||||||
});
|
|
||||||
|
|
||||||
Map<String, dynamic> toMap() => {
|
Map<String, dynamic> toMap() => {
|
||||||
'annotationsJson': annotationsJson,
|
'annotationsJson': annotationsJson,
|
||||||
'lastModified': lastModified.toIso8601String(),
|
'lastModified': lastModified.toIso8601String(),
|
||||||
};
|
};
|
||||||
|
|
||||||
factory StoredAnnotation.fromMap(Map<dynamic, dynamic> map) {
|
factory StoredAnnotation.fromMap(Map<dynamic, dynamic> map) {
|
||||||
return StoredAnnotation(
|
return StoredAnnotation(
|
||||||
@@ -52,11 +49,11 @@ class PendingAnnotationUpload {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Map<String, dynamic> toMap() => {
|
Map<String, dynamic> toMap() => {
|
||||||
'sheetUuid': sheetUuid,
|
'sheetUuid': sheetUuid,
|
||||||
'page': page,
|
'page': page,
|
||||||
'annotationsJson': annotationsJson,
|
'annotationsJson': annotationsJson,
|
||||||
'lastModified': lastModified.toIso8601String(),
|
'lastModified': lastModified.toIso8601String(),
|
||||||
};
|
};
|
||||||
|
|
||||||
factory PendingAnnotationUpload.fromMap(Map<dynamic, dynamic> map) {
|
factory PendingAnnotationUpload.fromMap(Map<dynamic, dynamic> map) {
|
||||||
return PendingAnnotationUpload(
|
return PendingAnnotationUpload(
|
||||||
@@ -142,9 +139,8 @@ class StorageService {
|
|||||||
Future<Map<String, DateTime>> readSheetAccessTimes() async {
|
Future<Map<String, DateTime>> readSheetAccessTimes() async {
|
||||||
final box = await Hive.openBox(_sheetAccessTimesBox);
|
final box = await Hive.openBox(_sheetAccessTimesBox);
|
||||||
return box.toMap().map(
|
return box.toMap().map(
|
||||||
(key, value) =>
|
(key, value) => MapEntry(key as String, DateTime.parse(value as String)),
|
||||||
MapEntry(key as String, DateTime.parse(value as String)),
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Records when a sheet was last accessed.
|
/// Records when a sheet was last accessed.
|
||||||
@@ -308,8 +304,9 @@ class StorageService {
|
|||||||
Future<void> deleteAllAnnotations(String sheetUuid) async {
|
Future<void> deleteAllAnnotations(String sheetUuid) async {
|
||||||
final box = await Hive.openBox(_annotationsBox);
|
final box = await Hive.openBox(_annotationsBox);
|
||||||
final prefix = '${sheetUuid}_page_';
|
final prefix = '${sheetUuid}_page_';
|
||||||
final keysToDelete =
|
final keysToDelete = box.keys.where(
|
||||||
box.keys.where((key) => key is String && key.startsWith(prefix));
|
(key) => key is String && key.startsWith(prefix),
|
||||||
|
);
|
||||||
|
|
||||||
for (final key in keysToDelete.toList()) {
|
for (final key in keysToDelete.toList()) {
|
||||||
await box.delete(key);
|
await box.delete(key);
|
||||||
|
|||||||
Reference in New Issue
Block a user