fix init settings

This commit is contained in:
Schnitzel5 2024-11-09 00:27:11 +01:00
parent 34a451d374
commit 3d29a12fc4
2 changed files with 88 additions and 41 deletions

View file

@ -266,7 +266,7 @@ class Settings {
this.animeLibraryShowNumbersOfItems = false,
this.animeLibraryShowContinueReadingButton = false,
this.animeLibraryLocalSource,
this.sortLibraryAnime, // TODO add novel settings
this.sortLibraryAnime,
this.pagePreloadAmount = 6,
this.scaleType = ScaleType.fitScreen,
this.checkForExtensionUpdates = true,
@ -300,7 +300,19 @@ class Settings {
this.mangaGridSize,
this.animeGridSize,
this.disableSectionType = SectionType.all,
this.useLibass = true});
this.useLibass = true,
this.libraryFilterNovelDownloadType = 0,
this.libraryFilterNovelUnreadType = 0,
this.libraryFilterNovelStartedType = 0,
this.libraryFilterNovelBookMarkedType = 0,
this.novelLibraryShowCategoryTabs = false,
this.novelLibraryDownloadedChapters = false,
this.novelLibraryShowLanguage = false,
this.novelLibraryShowNumbersOfItems = false,
this.novelLibraryShowContinueReadingButton = false,
this.novelLibraryLocalSource,
this.sortLibraryNovel,
this.novelDisplayType = DisplayType.comfortableGrid});
Settings.fromJson(Map<String, dynamic> json) {
animatePageTransitions = json['animatePageTransitions'];
@ -455,6 +467,22 @@ class Settings {
disableSectionType =
SectionType.values[json['disableSectionType'] ?? SectionType.all];
useLibass = json['useLibass'];
libraryFilterNovelBookMarkedType = json['libraryFilterNovelBookMarkedType'];
libraryFilterNovelDownloadType = json['libraryFilterNovelDownloadType'];
libraryFilterNovelStartedType = json['libraryFilterNovelStartedType'];
libraryFilterNovelUnreadType = json['libraryFilterNovelUnreadType'];
novelLibraryShowCategoryTabs = json['novelLibraryShowCategoryTabs'];
novelLibraryDownloadedChapters = json['novelLibraryDownloadedChapters'];
novelLibraryShowLanguage = json['novelLibraryShowLanguage'];
novelLibraryShowNumbersOfItems = json['novelLibraryShowNumbersOfItems'];
novelLibraryShowContinueReadingButton =
json['novelLibraryShowContinueReadingButton'];
novelLibraryLocalSource = json['novelLibraryLocalSource'];
sortLibraryNovel = json['sortLibraryNovel'] != null
? SortLibraryManga.fromJson(json['sortLibraryNovel'])
: null;
novelDisplayType = DisplayType
.values[json['novelDisplayType'] ?? DisplayType.compactGrid.index];
}
Map<String, dynamic> toJson() => {
@ -554,7 +582,20 @@ class Settings {
'mangaGridSize': mangaGridSize,
'animeGridSize': animeGridSize,
'disableSectionType': disableSectionType.index,
'useLibass': useLibass
'useLibass': useLibass,
'libraryFilterNovelBookMarkedType': libraryFilterNovelBookMarkedType,
'libraryFilterNovelDownloadType': libraryFilterNovelDownloadType,
'libraryFilterNovelStartedType': libraryFilterNovelStartedType,
'libraryFilterNovelUnreadType': libraryFilterNovelUnreadType,
'novelLibraryShowCategoryTabs': novelLibraryShowCategoryTabs,
'novelLibraryDownloadedChapters': novelLibraryDownloadedChapters,
'novelLibraryShowLanguage': novelLibraryShowLanguage,
'novelLibraryShowNumbersOfItems': novelLibraryShowNumbersOfItems,
'novelLibraryShowContinueReadingButton':
novelLibraryShowContinueReadingButton,
'novelLibraryLocalSource': novelLibraryLocalSource,
'sortLibraryNovel': sortLibraryNovel?.toJson(),
'novelDisplayType': novelDisplayType.index,
};
}

View file

@ -171,7 +171,7 @@ class ReaderController extends _$ReaderController {
history = History(
mangaId: getManga().id,
date: DateTime.now().millisecondsSinceEpoch.toString(),
isManga: getManga().isManga,
itemType: getManga().itemType,
chapterId: chapter.id)
..chapter.value = chapter;
} else {
@ -379,7 +379,7 @@ extension ChapterExtensions on Chapter {
final tracks = isar.tracks
.filter()
.idIsNotNull()
.isMangaEqualTo(manga.isManga)
.isMangaEqualTo(manga.itemType == ItemType.manga)
.mangaIdEqualTo(manga.id!)
.findAllSync();
@ -398,15 +398,17 @@ extension ChapterExtensions on Chapter {
track.status = TrackStatus.completed;
track.finishedReadingDate = DateTime.now().millisecondsSinceEpoch;
} else {
track.status =
manga.isManga! ? TrackStatus.reading : TrackStatus.watching;
track.status = manga.itemType == ItemType.manga
? TrackStatus.reading
: TrackStatus.watching;
if (track.lastChapterRead == 1) {
track.startedReadingDate = DateTime.now().millisecondsSinceEpoch;
}
}
}
ref
.read(trackStateProvider(track: track, isManga: manga.isManga)
.read(trackStateProvider(
track: track, isManga: manga.itemType == ItemType.manga)
.notifier)
.updateManga();
}
@ -418,47 +420,51 @@ extension MangaExtensions on Manga {
List<Chapter> getFilteredChapterList() {
final data = this.chapters.toList().reversed.toList();
final filterUnread = (isar.settings
.getSync(227)!
.chapterFilterUnreadList!
.where((element) => element.mangaId == id)
.toList()
.firstOrNull ?? ChapterFilterUnread(
mangaId: id,
type: 0,
))
.getSync(227)!
.chapterFilterUnreadList!
.where((element) => element.mangaId == id)
.toList()
.firstOrNull ??
ChapterFilterUnread(
mangaId: id,
type: 0,
))
.type!;
final filterBookmarked = (isar.settings
.getSync(227)!
.chapterFilterBookmarkedList!
.where((element) => element.mangaId == id)
.toList()
.firstOrNull ?? ChapterFilterBookmarked(
mangaId: id,
type: 0,
))
.getSync(227)!
.chapterFilterBookmarkedList!
.where((element) => element.mangaId == id)
.toList()
.firstOrNull ??
ChapterFilterBookmarked(
mangaId: id,
type: 0,
))
.type!;
final filterDownloaded = (isar.settings
.getSync(227)!
.chapterFilterDownloadedList!
.where((element) => element.mangaId == id)
.toList()
.firstOrNull ?? ChapterFilterDownloaded(
mangaId: id,
type: 0,
))
.getSync(227)!
.chapterFilterDownloadedList!
.where((element) => element.mangaId == id)
.toList()
.firstOrNull ??
ChapterFilterDownloaded(
mangaId: id,
type: 0,
))
.type!;
final sortChapter = (isar.settings
.getSync(227)!
.sortChapterList!
.where((element) => element.mangaId == id)
.toList()
.firstOrNull ?? SortChapter(
mangaId: id,
index: 1,
reverse: false,
))
.getSync(227)!
.sortChapterList!
.where((element) => element.mangaId == id)
.toList()
.firstOrNull ??
SortChapter(
mangaId: id,
index: 1,
reverse: false,
))
.index;
final filterScanlator = _getFilterScanlator(this) ?? [];
List<Chapter>? chapterList;