mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-30 17:41:52 +01:00
Update insertOrRemoveChapters method
This commit is contained in:
parent
67a2e99cc1
commit
74ccd8bd24
@ -62,22 +62,28 @@ public class ChapterManagerImpl extends BaseManager implements ChapterManager {
|
||||
return Observable.create(subscriber -> {
|
||||
List<Chapter> dbChapters = prepareGet(manga).executeAsBlocking();
|
||||
|
||||
Observable<List<Chapter>> newChaptersObs =
|
||||
Observable<Integer> newChaptersObs =
|
||||
Observable.from(chapters)
|
||||
.filter(c -> !dbChapters.contains(c))
|
||||
.toList();
|
||||
.toList()
|
||||
.flatMap(this::insertChapters)
|
||||
.map(PutResults::numberOfInserts);
|
||||
|
||||
Observable<List<Chapter>> deletedChaptersObs =
|
||||
Observable<Integer> deletedChaptersObs =
|
||||
Observable.from(dbChapters)
|
||||
.filter(c -> !chapters.contains(c))
|
||||
.toList();
|
||||
.toList()
|
||||
.flatMap(this::deleteChapters)
|
||||
.map(result -> result.results().size());
|
||||
|
||||
Observable.zip(newChaptersObs, deletedChaptersObs,
|
||||
(newChapters, deletedChapters) -> {
|
||||
insertChapters(newChapters).subscribe();
|
||||
deleteChapters(deletedChapters).subscribe();
|
||||
ArrayList<Integer> results = new ArrayList<>();
|
||||
results.add(newChapters);
|
||||
results.add(deletedChapters);
|
||||
subscriber.onNext(results);
|
||||
subscriber.onCompleted();
|
||||
return null;
|
||||
return results;
|
||||
}).subscribe();
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user