mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-21 16:01:58 +00:00
change: switch to async fetch for isar due to lag in large libraries
This commit is contained in:
parent
816aa6176e
commit
ebe2b3fd6f
1 changed files with 25 additions and 23 deletions
|
|
@ -362,14 +362,14 @@ Future<void> pushToMangaReaderDetail({
|
||||||
.sourceEqualTo(manga.source)
|
.sourceEqualTo(manga.source)
|
||||||
.isEmptySync();
|
.isEmptySync();
|
||||||
if (empty) {
|
if (empty) {
|
||||||
isar.writeTxnSync(() {
|
await isar.writeTxn(() async {
|
||||||
isar.mangas.putSync(
|
await isar.mangas.put(
|
||||||
manga..updatedAt = DateTime.now().millisecondsSinceEpoch,
|
manga..updatedAt = DateTime.now().millisecondsSinceEpoch,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
isar.writeTxnSync(() {
|
await isar.writeTxn(() async {
|
||||||
isar.mangas.putSync(manga);
|
await isar.mangas.put(manga);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -391,8 +391,8 @@ Future<void> pushToMangaReaderDetail({
|
||||||
|
|
||||||
final mang = isar.mangas.getSync(mangaId);
|
final mang = isar.mangas.getSync(mangaId);
|
||||||
if (mang!.sourceId == null && !(mang.isLocalArchive ?? false)) {
|
if (mang!.sourceId == null && !(mang.isLocalArchive ?? false)) {
|
||||||
isar.writeTxnSync(() {
|
await isar.writeTxn(() async {
|
||||||
isar.mangas.putSync(mang..sourceId = sourceId);
|
await isar.mangas.put(mang..sourceId = sourceId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
final settings = isar.settings.getSync(227)!;
|
final settings = isar.settings.getSync(227)!;
|
||||||
|
|
@ -401,7 +401,7 @@ Future<void> pushToMangaReaderDetail({
|
||||||
.where((element) => element.mangaId == mangaId)
|
.where((element) => element.mangaId == mangaId)
|
||||||
.toList();
|
.toList();
|
||||||
if (checkIfExist.isEmpty) {
|
if (checkIfExist.isEmpty) {
|
||||||
isar.writeTxnSync(() {
|
await isar.writeTxn(() async {
|
||||||
List<SortChapter>? sortChapterList = [];
|
List<SortChapter>? sortChapterList = [];
|
||||||
for (var sortChapter in settings.sortChapterList ?? []) {
|
for (var sortChapter in settings.sortChapterList ?? []) {
|
||||||
sortChapterList.add(sortChapter);
|
sortChapterList.add(sortChapter);
|
||||||
|
|
@ -426,7 +426,7 @@ Future<void> pushToMangaReaderDetail({
|
||||||
ChapterFilterDownloaded()..mangaId = mangaId,
|
ChapterFilterDownloaded()..mangaId = mangaId,
|
||||||
);
|
);
|
||||||
chapterFilterUnreadList.add(ChapterFilterUnread()..mangaId = mangaId);
|
chapterFilterUnreadList.add(ChapterFilterUnread()..mangaId = mangaId);
|
||||||
isar.settings.putSync(
|
await isar.settings.put(
|
||||||
settings
|
settings
|
||||||
..sortChapterList = sortChapterList
|
..sortChapterList = sortChapterList
|
||||||
..chapterFilterBookmarkedList = chapterFilterBookmarkedList
|
..chapterFilterBookmarkedList = chapterFilterBookmarkedList
|
||||||
|
|
@ -437,22 +437,24 @@ Future<void> pushToMangaReaderDetail({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!addToFavourite) {
|
if (!addToFavourite) {
|
||||||
if (useMaterialRoute) {
|
if (context.mounted) {
|
||||||
await Navigator.push(
|
if (useMaterialRoute) {
|
||||||
context,
|
await Navigator.push(
|
||||||
createRoute(page: MangaReaderDetail(mangaId: mangaId)),
|
context,
|
||||||
);
|
createRoute(page: MangaReaderDetail(mangaId: mangaId)),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await context.push('/manga-reader/detail', extra: mangaId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await context.push('/manga-reader/detail', extra: mangaId);
|
final getManga = isar.mangas.filter().idEqualTo(mangaId).findFirstSync()!;
|
||||||
|
await isar.writeTxn(() async {
|
||||||
|
await isar.mangas.put(
|
||||||
|
getManga
|
||||||
|
..favorite = !getManga.favorite!
|
||||||
|
..updatedAt = DateTime.now().millisecondsSinceEpoch,
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
final getManga = isar.mangas.filter().idEqualTo(mangaId).findFirstSync()!;
|
|
||||||
isar.writeTxnSync(() {
|
|
||||||
isar.mangas.putSync(
|
|
||||||
getManga
|
|
||||||
..favorite = !getManga.favorite!
|
|
||||||
..updatedAt = DateTime.now().millisecondsSinceEpoch,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue