mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	Make sure the answer from MAL is successful before updating DB.
This commit is contained in:
		| @@ -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()) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user