From ccf0a46a139edd7fc13d41bda8c405e33d04b7bd Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Sat, 17 Aug 2019 12:43:16 +0200 Subject: [PATCH] Insert greader API writeToken after getting it --- .../java/com/readrops/app/database/dao/AccountDao.java | 3 +++ .../readrops/app/repositories/FreshRSSRepository.java | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/readrops/app/database/dao/AccountDao.java b/app/src/main/java/com/readrops/app/database/dao/AccountDao.java index fbf1c536..a74ffea2 100644 --- a/app/src/main/java/com/readrops/app/database/dao/AccountDao.java +++ b/app/src/main/java/com/readrops/app/database/dao/AccountDao.java @@ -28,4 +28,7 @@ public abstract class AccountDao implements BaseDao { @Query("Select count(*) From Account") public abstract Integer getAccountCount(); + + @Query("Update Account set writeToken = :writeToken Where id = :accountId") + public abstract void updateWriteToken(int accountId, String writeToken); } diff --git a/app/src/main/java/com/readrops/app/repositories/FreshRSSRepository.java b/app/src/main/java/com/readrops/app/repositories/FreshRSSRepository.java index 81a59c18..4959e78e 100644 --- a/app/src/main/java/com/readrops/app/repositories/FreshRSSRepository.java +++ b/app/src/main/java/com/readrops/app/repositories/FreshRSSRepository.java @@ -121,10 +121,13 @@ public class FreshRSSRepository extends ARepository { if (account.getWriteToken() == null) { return api.getWriteToken() - .flatMapCompletable(writeToken -> api. - markItemReadUnread(read, item.getRemoteId(), writeToken)); + .flatMapCompletable(writeToken -> { + database.accountDao().updateWriteToken(account.getId(), writeToken); + + return api.markItemReadUnread(read, item.getRemoteId(), writeToken).concatWith(super.setItemReadState(item, read)); + }); } else { - return api.markItemReadUnread(read, item.getRemoteId(), account.getWriteToken()); + return api.markItemReadUnread(read, item.getRemoteId(), account.getWriteToken()).concatWith(super.setItemReadState(item, read)); } }