Insert greader API writeToken after getting it

This commit is contained in:
Shinokuni 2019-08-17 12:43:16 +02:00
parent 46d4d8a868
commit ccf0a46a13
2 changed files with 9 additions and 3 deletions

View File

@ -28,4 +28,7 @@ public abstract class AccountDao implements BaseDao<Account> {
@Query("Select count(*) From Account") @Query("Select count(*) From Account")
public abstract Integer getAccountCount(); public abstract Integer getAccountCount();
@Query("Update Account set writeToken = :writeToken Where id = :accountId")
public abstract void updateWriteToken(int accountId, String writeToken);
} }

View File

@ -121,10 +121,13 @@ public class FreshRSSRepository extends ARepository {
if (account.getWriteToken() == null) { if (account.getWriteToken() == null) {
return api.getWriteToken() return api.getWriteToken()
.flatMapCompletable(writeToken -> api. .flatMapCompletable(writeToken -> {
markItemReadUnread(read, item.getRemoteId(), writeToken)); database.accountDao().updateWriteToken(account.getId(), writeToken);
return api.markItemReadUnread(read, item.getRemoteId(), writeToken).concatWith(super.setItemReadState(item, read));
});
} else { } else {
return api.markItemReadUnread(read, item.getRemoteId(), account.getWriteToken()); return api.markItemReadUnread(read, item.getRemoteId(), account.getWriteToken()).concatWith(super.setItemReadState(item, read));
} }
} }