diff --git a/lib/db/collections_db.dart b/lib/db/collections_db.dart index b553830ab..cc9436bc1 100644 --- a/lib/db/collections_db.dart +++ b/lib/db/collections_db.dart @@ -52,7 +52,7 @@ class CollectionsDB { $columnType TEXT NOT NULL, $columnEncryptedPath TEXT, $columnPathDecryptionNonce TEXT, - $columnCreationTime TEXT NOT NULL, + $columnCreationTime TEXT NOT NULL ) '''); } @@ -98,7 +98,7 @@ class CollectionsDB { row[columnEncryptedKey] = collection.encryptedKey; row[columnKeyDecryptionNonce] = collection.keyDecryptionNonce; row[columnName] = collection.name; - row[columnType] = collection.type; + row[columnType] = typeToString(collection.type); row[columnEncryptedPath] = collection.encryptedPath; row[columnPathDecryptionNonce] = collection.pathDecryptionNonce; row[columnCreationTime] = collection.creationTime; @@ -112,7 +112,7 @@ class CollectionsDB { row[columnEncryptedKey], row[columnKeyDecryptionNonce], row[columnName], - row[columnType], + typeFromString(row[columnType]), row[columnEncryptedPath], row[columnPathDecryptionNonce], int.parse(row[columnCreationTime]), diff --git a/lib/models/collection.dart b/lib/models/collection.dart index d0973166d..718d6b21b 100644 --- a/lib/models/collection.dart +++ b/lib/models/collection.dart @@ -65,7 +65,7 @@ class Collection { 'encryptedKey': encryptedKey, 'keyDecryptionNonce': keyDecryptionNonce, 'name': name, - 'type': type.toString(), + 'type': typeToString(type), 'creationTime': creationTime, 'encryptedPath': encryptedPath, 'pathDecryptionNonce': pathDecryptionNonce, @@ -82,7 +82,7 @@ class Collection { map['encryptedKey'], map['keyDecryptionNonce'], map['name'], - fromString(map['type']), + typeFromString(map['type']), map['encryptedPath'], map['pathDecryptionNonce'], map['creationTime'], @@ -132,7 +132,7 @@ class Collection { } } -CollectionType fromString(String type) { +CollectionType typeFromString(String type) { switch (type) { case "folder": return CollectionType.folder; @@ -142,6 +142,17 @@ CollectionType fromString(String type) { return CollectionType.album; } +String typeToString(CollectionType type) { + switch (type) { + case CollectionType.folder: + return "folder"; + case CollectionType.favorites: + return "favorites"; + default: + return "album"; + } +} + enum CollectionType { folder, favorites,