Skip to content

Commit

Permalink
fix negative unread counts #216
Browse files Browse the repository at this point in the history
  • Loading branch information
yang991178 committed Dec 15, 2021
1 parent 82a6a2c commit 4e842e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/scripts/models/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/models/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4e842e6

Please sign in to comment.