mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 22:59:18 +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);
|
MangaSyncService sync = syncManager.getSyncService(mangaSync.sync_id);
|
||||||
|
|
||||||
subscriptions.add(Observable.defer(() -> sync.update(mangaSync))
|
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())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(result -> {
|
.subscribe(result -> {
|
||||||
|
@ -113,8 +113,9 @@ public class MyAnimeListPresenter extends BasePresenter<MyAnimeListFragment> {
|
|||||||
manga.manga_id = this.manga.id;
|
manga.manga_id = this.manga.id;
|
||||||
add(myAnimeList.bind(manga)
|
add(myAnimeList.bind(manga)
|
||||||
.flatMap(response -> {
|
.flatMap(response -> {
|
||||||
if (response.code() == 200 || response.code() == 201)
|
if (response.isSuccessful()) {
|
||||||
return Observable.just(manga);
|
return Observable.just(manga);
|
||||||
|
}
|
||||||
return Observable.error(new Exception("Could not add manga"));
|
return Observable.error(new Exception("Could not add manga"));
|
||||||
})
|
})
|
||||||
.flatMap(manga2 -> db.insertMangaSync(manga2).createObservable())
|
.flatMap(manga2 -> db.insertMangaSync(manga2).createObservable())
|
||||||
|
Loading…
Reference in New Issue
Block a user