nextcloud / news

:newspaper: RSS/Atom feed reader
https://apps.nextcloud.com/apps/news
GNU Affero General Public License v3.0
862 stars 186 forks source link

Unread Counter becomes negative #2839

Open wofferl opened 3 hours ago

wofferl commented 3 hours ago

IMPORTANT

Read and tick the following checkbox after you have created the issue or place an x inside the brackets ;)

Explain the Problem

When reading news the unread counter becomes negative at the end.

From the code it checks the state of item.unread before decreasing the counter.

        [FEED_ITEM_ACTION_TYPES.MARK_READ](
                { commit, dispatch }: ActionParams<ItemState>,
                { item }: { item: FeedItem },
        ) {
                ItemService.markRead(item, true)

                if (item.unread) {
                        commit(FEED_ITEM_MUTATION_TYPES.SET_UNREAD_COUNT, state.unreadCount - 1)

                        dispatch(FEED_ACTION_TYPES.MODIFY_FEED_UNREAD_COUNT, { feedId: item.feedId, delta: -1 })
                }
                item.unread = false
                commit(FEED_ITEM_MUTATION_TYPES.UPDATE_ITEM, { item })
        },

So either the state for item.unread has not really been set yet or an API call in between has changed the state of the feed or item.

Also MARK_READ is called every time you click an item or if you use key navigation to go through the items. This should be avoided.

Steps to Reproduce

System Information

Contents of nextcloud/data/nextcloud.log ```json Paste output here ```
Contents of Browser Error Console Read http://ggnome.com/wiki/Using_The_Browser_Error_Console if you are unsure what to put here ``` Paste output here ```
wofferl commented 3 hours ago

Since this is not reproducibly if I go fast through multiple hundred items it would be nice, if someone has the them behaviour, to post some info here.

How did you go through the news (key navigation, mouse scroll, cursor or pgdn scroll)? Did you click items? Did you scroll forth and back in the list? Ho many items where there approximately in the list?