Select all option now respects the feed filter

This commit is contained in:
Shinokuni 2019-04-26 09:37:55 +02:00
parent 245719e2f6
commit aeb4994c2a
2 changed files with 8 additions and 2 deletions

View File

@ -40,6 +40,9 @@ public interface ItemDao {
@Query("Update Item set read = :readState")
void setAllItemsReadState(int readState);
@Query("Update Item set read = :readState Where feed_id = :feedId")
void setAllItemsReadState(int feedId, int readState);
@Query("Update Item set read_it_later = 1 Where id = :itemId")
void setReadItLater(int itemId);

View File

@ -100,7 +100,7 @@ public class MainViewModel extends AndroidViewModel {
public void setFilterFeedId(int filterFeedId) {
queryBuilder.setFilterFeedId(filterFeedId);
}
public MediatorLiveData<PagedList<ItemWithFeed>> getItemsWithFeed() {
return itemsWithFeed;
}
@ -152,7 +152,10 @@ public class MainViewModel extends AndroidViewModel {
public Completable setAllItemsReadState(boolean read) {
return Completable.create(emitter -> {
db.itemDao().setAllItemsReadState(read ? 1 : 0);
if (queryBuilder.getFilterType() == FilterType.FEED_FILTER)
db.itemDao().setAllItemsReadState(queryBuilder.getFilterFeedId(), read ? 1 : 0);
else
db.itemDao().setAllItemsReadState(read ? 1 : 0);
emitter.onComplete();
});
}