diff --git a/lib/models/category.dart b/lib/models/category.dart index 551bcc6d..4d4d05c2 100644 --- a/lib/models/category.dart +++ b/lib/models/category.dart @@ -19,7 +19,7 @@ class Category { Category.fromJson(Map json) { id = json['id']; name = json['name']; - forItemType = json['forItemType']; + forItemType = ItemType.values[json['forItemType'] ?? 0]; } Category.fromJsonV1(Map json) { @@ -33,5 +33,5 @@ class Category { } Map toJson() => - {'id': id, 'name': name, 'forItemType': forItemType}; + {'id': id, 'name': name, 'forItemType': forItemType.index}; } diff --git a/lib/models/history.dart b/lib/models/history.dart index 367b353f..802dcd9f 100644 --- a/lib/models/history.dart +++ b/lib/models/history.dart @@ -34,7 +34,7 @@ class History { chapterId = json['chapterId']; date = json['date']; id = json['id']; - itemType = json['itemType']; + itemType = ItemType.values[json['itemType'] ?? 0]; mangaId = json['mangaId']; } @@ -54,7 +54,7 @@ class History { 'chapterId': chapterId, 'date': date, 'id': id, - 'itemType': itemType, + 'itemType': itemType.index, 'mangaId': mangaId }; } diff --git a/lib/models/manga.dart b/lib/models/manga.dart index da21256e..4473cabc 100644 --- a/lib/models/manga.dart +++ b/lib/models/manga.dart @@ -87,7 +87,7 @@ class Manga { id = json['id']; imageUrl = json['imageUrl']; isLocalArchive = json['isLocalArchive']; - itemType = ItemType.values[json['itemType']]; + itemType = ItemType.values[json['itemType'] ?? 0]; lang = json['lang']; lastRead = json['lastRead']; lastUpdate = json['lastUpdate']; diff --git a/lib/models/source.dart b/lib/models/source.dart index 9f3e812c..e6c0f422 100644 --- a/lib/models/source.dart +++ b/lib/models/source.dart @@ -171,7 +171,7 @@ class Source { 'isAdded': isAdded, 'isFullData': isFullData, 'isManga': isManga, - 'itemType': itemType, + 'itemType': itemType.index, 'isNsfw': isNsfw, 'isPinned': isPinned, 'lang': lang,