mirror of https://github.com/readrops/Readrops.git
Put methods setAllItemsReadState and setAllFeedItemsReadState int repository to get better control by account type repository
This commit is contained in:
parent
dbd5fe060b
commit
c9ae3a5cb5
|
@ -37,11 +37,11 @@ public abstract class ItemDao implements BaseDao<Item> {
|
|||
@Query("Update Item Set read_changed = :readChanged, read = :readState Where id = :itemId")
|
||||
public abstract void setReadState(int itemId, int readState, int readChanged);
|
||||
|
||||
@Query("Update Item set read_changed = 1, read = :readState")
|
||||
public abstract void setAllItemsReadState(int readState);
|
||||
@Query("Update Item set read_changed = 1, read = :readState Where feed_id In (Select id From Feed Where account_id = :accountId)")
|
||||
public abstract void setAllItemsReadState(int readState, int accountId);
|
||||
|
||||
@Query("Update Item set read_changed = 1, read = :readState Where feed_id = :feedId")
|
||||
public abstract void setAllItemsReadState(int feedId, int readState);
|
||||
public abstract void setAllFeedItemsReadState(int feedId, int readState);
|
||||
|
||||
@Query("Update Item set read_it_later = 1 Where id = :itemId")
|
||||
public abstract void setReadItLater(int itemId);
|
||||
|
|
|
@ -85,6 +85,20 @@ public abstract class ARepository {
|
|||
});
|
||||
}
|
||||
|
||||
public Completable setAllItemsReadState(Boolean read) {
|
||||
return Completable.create(emitter -> {
|
||||
database.itemDao().setAllItemsReadState(read ? 1 : 0, account.getId());
|
||||
emitter.onComplete();
|
||||
});
|
||||
}
|
||||
|
||||
public Completable setAllFeedItemsReadState(int feedId, boolean read) {
|
||||
return Completable.create(emitter -> {
|
||||
database.itemDao().setAllFeedItemsReadState(feedId, read ? 1 : 0);
|
||||
emitter.onComplete();
|
||||
});
|
||||
}
|
||||
|
||||
public Single<Integer> getFeedCount(int accountId) {
|
||||
return Single.create(emitter -> emitter.onSuccess(database.feedDao().getFeedCount(accountId)));
|
||||
}
|
||||
|
|
|
@ -237,7 +237,6 @@ public class MainViewModel extends AndroidViewModel {
|
|||
|
||||
//endregion
|
||||
|
||||
|
||||
//region Item read state
|
||||
|
||||
public Completable setItemReadState(ItemWithFeed itemWithFeed, boolean read) {
|
||||
|
@ -255,13 +254,10 @@ public class MainViewModel extends AndroidViewModel {
|
|||
}
|
||||
|
||||
public Completable setAllItemsReadState(boolean read) {
|
||||
return Completable.create(emitter -> {
|
||||
if (queryBuilder.getFilterType() == FilterType.FEED_FILTER)
|
||||
db.itemDao().setAllItemsReadState(queryBuilder.getFilterFeedId(), read ? 1 : 0);
|
||||
else
|
||||
db.itemDao().setAllItemsReadState(read ? 1 : 0);
|
||||
emitter.onComplete();
|
||||
});
|
||||
if (queryBuilder.getFilterType() == FilterType.FEED_FILTER)
|
||||
return repository.setAllFeedItemsReadState(queryBuilder.getFilterFeedId(), read);
|
||||
else
|
||||
return repository.setAllItemsReadState(read);
|
||||
}
|
||||
|
||||
public Completable setItemReadItLater(int itemId) {
|
||||
|
|
Loading…
Reference in New Issue