Handle read/star state for local account
This commit is contained in:
parent
d600633aca
commit
1011eee9df
@ -115,9 +115,16 @@ public abstract class ARepository {
|
||||
}
|
||||
|
||||
public Completable setItemReadState(Item item) {
|
||||
return database.itemStateChangesDao().upsertItemReadStateChange(item, account.getId())
|
||||
.andThen(database.itemStateDao().upsertItemReadState(new ItemState(0, item.isRead(),
|
||||
item.isStarred(), item.getRemoteId(), account.getId())));
|
||||
if (account.getConfig().useSeparateState()) {
|
||||
return database.itemStateChangesDao().upsertItemReadStateChange(item, account.getId())
|
||||
.andThen(database.itemStateDao().upsertItemReadState(new ItemState(0, item.isRead(),
|
||||
item.isStarred(), item.getRemoteId(), account.getId())));
|
||||
} else if (account.isLocal()) {
|
||||
return database.itemDao().setReadState(item.getId(), item.isRead());
|
||||
} else { // TODO nextcloud case, use only ItemStateChange table
|
||||
return Completable.complete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Completable setAllItemsReadState(boolean read) {
|
||||
@ -129,9 +136,15 @@ public abstract class ARepository {
|
||||
}
|
||||
|
||||
public Completable setItemStarState(Item item) {
|
||||
return database.itemStateChangesDao().upsertItemStarStateChange(item, account.getId())
|
||||
.andThen(database.itemStateDao().upsertItemStarState(new ItemState(0, item.isRead(),
|
||||
item.isStarred(), item.getRemoteId(), account.getId())));
|
||||
if (account.getConfig().useSeparateState()) {
|
||||
return database.itemStateChangesDao().upsertItemStarStateChange(item, account.getId())
|
||||
.andThen(database.itemStateDao().upsertItemStarState(new ItemState(0, item.isRead(),
|
||||
item.isStarred(), item.getRemoteId(), account.getId())));
|
||||
} else if (account.isLocal()) {
|
||||
return database.itemDao().setStarState(item.getId(), item.isRead());
|
||||
} else { // TODO nextcloud case, use only ItemStateChange table
|
||||
return Completable.complete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,9 @@ public interface ItemDao extends BaseDao<Item> {
|
||||
@Query("Update Item Set read = :read Where id = :itemId")
|
||||
Completable setReadState(int itemId, boolean read);
|
||||
|
||||
@Query("Update Item set starred = :starred Where id = :itemId")
|
||||
Completable setStarState(int itemId, boolean starred);
|
||||
|
||||
@Query("Update Item set read = :readState Where feed_id In (Select id From Feed Where account_id = :accountId)")
|
||||
Completable setAllItemsReadState(int readState, int accountId);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user