mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-05-25 01:02:33 +00:00
change: switch to async fetch for isar due to lag in large libraries
This commit is contained in:
parent
98b3121c04
commit
232ae8ea86
1 changed files with 25 additions and 23 deletions
|
|
@ -320,14 +320,14 @@ Future<void> pushToMangaReaderDetail({
|
|||
.sourceEqualTo(manga.source)
|
||||
.isEmptySync();
|
||||
if (empty) {
|
||||
isar.writeTxnSync(() {
|
||||
isar.mangas.putSync(
|
||||
await isar.writeTxn(() async {
|
||||
await isar.mangas.put(
|
||||
manga..updatedAt = DateTime.now().millisecondsSinceEpoch,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
isar.writeTxnSync(() {
|
||||
isar.mangas.putSync(manga);
|
||||
await isar.writeTxn(() async {
|
||||
await isar.mangas.put(manga);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -349,8 +349,8 @@ Future<void> pushToMangaReaderDetail({
|
|||
|
||||
final mang = isar.mangas.getSync(mangaId);
|
||||
if (mang!.sourceId == null && !(mang.isLocalArchive ?? false)) {
|
||||
isar.writeTxnSync(() {
|
||||
isar.mangas.putSync(mang..sourceId = sourceId);
|
||||
await isar.writeTxn(() async {
|
||||
await isar.mangas.put(mang..sourceId = sourceId);
|
||||
});
|
||||
}
|
||||
final settings = isar.settings.getSync(227)!;
|
||||
|
|
@ -359,7 +359,7 @@ Future<void> pushToMangaReaderDetail({
|
|||
.where((element) => element.mangaId == mangaId)
|
||||
.toList();
|
||||
if (checkIfExist.isEmpty) {
|
||||
isar.writeTxnSync(() {
|
||||
await isar.writeTxn(() async {
|
||||
List<SortChapter>? sortChapterList = [];
|
||||
for (var sortChapter in settings.sortChapterList ?? []) {
|
||||
sortChapterList.add(sortChapter);
|
||||
|
|
@ -384,7 +384,7 @@ Future<void> pushToMangaReaderDetail({
|
|||
ChapterFilterDownloaded()..mangaId = mangaId,
|
||||
);
|
||||
chapterFilterUnreadList.add(ChapterFilterUnread()..mangaId = mangaId);
|
||||
isar.settings.putSync(
|
||||
await isar.settings.put(
|
||||
settings
|
||||
..sortChapterList = sortChapterList
|
||||
..chapterFilterBookmarkedList = chapterFilterBookmarkedList
|
||||
|
|
@ -395,22 +395,24 @@ Future<void> pushToMangaReaderDetail({
|
|||
});
|
||||
}
|
||||
if (!addToFavourite) {
|
||||
if (useMaterialRoute) {
|
||||
await Navigator.push(
|
||||
context,
|
||||
createRoute(page: MangaReaderDetail(mangaId: mangaId)),
|
||||
);
|
||||
if (context.mounted) {
|
||||
if (useMaterialRoute) {
|
||||
await Navigator.push(
|
||||
context,
|
||||
createRoute(page: MangaReaderDetail(mangaId: mangaId)),
|
||||
);
|
||||
} else {
|
||||
await context.push('/manga-reader/detail', extra: mangaId);
|
||||
}
|
||||
} 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