mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 00:55:08 +01:00
Make sure the answer from MAL is successful before updating DB.
This commit is contained in:
parent
a32c1b5eb2
commit
5f44e5d492
@ -61,7 +61,12 @@ public class UpdateMangaSyncService extends Service {
|
||||
MangaSyncService sync = syncManager.getSyncService(mangaSync.sync_id);
|
||||
|
||||
subscriptions.add(Observable.defer(() -> sync.update(mangaSync))
|
||||
.flatMap(response -> db.insertMangaSync(mangaSync).createObservable())
|
||||
.flatMap(response -> {
|
||||
if (response.isSuccessful()) {
|
||||
return db.insertMangaSync(mangaSync).createObservable();
|
||||
}
|
||||
return Observable.error(new Exception("Could not update MAL"));
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(result -> {
|
||||
|
@ -113,8 +113,9 @@ public class MyAnimeListPresenter extends BasePresenter<MyAnimeListFragment> {
|
||||
manga.manga_id = this.manga.id;
|
||||
add(myAnimeList.bind(manga)
|
||||
.flatMap(response -> {
|
||||
if (response.code() == 200 || response.code() == 201)
|
||||
if (response.isSuccessful()) {
|
||||
return Observable.just(manga);
|
||||
}
|
||||
return Observable.error(new Exception("Could not add manga"));
|
||||
})
|
||||
.flatMap(manga2 -> db.insertMangaSync(manga2).createObservable())
|
||||
|
Loading…
Reference in New Issue
Block a user