fix negative unread counts #216

This commit is contained in:
Bruce Liu 2021-12-15 14:39:11 +08:00
parent 82a6a2c170
commit 4e842e6420
2 changed files with 5 additions and 3 deletions

View File

@ -312,7 +312,8 @@ const markUnreadDone = (item: RSSItem): ItemActionTypes => ({
})
export function markRead(item: RSSItem): AppThunk {
return dispatch => {
return (dispatch, getState) => {
item = getState().items[item._id]
if (!item.hasRead) {
db.itemsDB
.update(db.items)
@ -377,7 +378,8 @@ export function markAllRead(
}
export function markUnread(item: RSSItem): AppThunk {
return dispatch => {
return (dispatch, getState) => {
item = getState().items[item._id]
if (item.hasRead) {
db.itemsDB
.update(db.items)

View File

@ -483,7 +483,7 @@ export function sourceReducer(
}
case MARK_ALL_READ: {
let nextState = { ...state }
action.sids.map((sid, i) => {
action.sids.forEach((sid) => {
nextState[sid] = {
...state[sid],
unreadCount: action.time ? state[sid].unreadCount : 0,