Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: "jump down" unread counter not clearing #4648

Merged
merged 3 commits into from
Feb 17, 2025

Conversation

WofWca
Copy link
Collaborator

@WofWca WofWca commented Feb 15, 2025

Reproduction steps:

  1. Open a chat.
  2. Scroll it up.
  3. Receive a message or a few in this chat.
  4. Scroll down to read all the new messages.
    The counter will be updating as you read the messages, as expected.
  5. Scroll up a bit.

The "jump down" button will appear again,
but with an incorrect count.

The bug was introduced in 1a752fa
(#4594).

This commit somewhat reverts it, i.e. ensures that
useUnreadCount does not lose its state when we start / stop
displaying the "jump down" button.

Reproduction steps:
1. Open a chat.
2. Scroll it up.
3. Receive a message or a few in this chat.
4. Scroll down to read all the new messages.
  The counter will be updating as you read the messages, as expected.
5. Scroll up a bit.

The "jump down" button will appear again,
but with an incorrect count.

The bug was introduced in 1a752fa
(#4594).

This commit somewhat reverts it, i.e. ensures that
`useUnreadCount` does not lose its state when we start / stop
displaying the "jump down" button.
Copy link
Member

@nicodh nicodh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and the behaviour is the same as in main, so the bug is not fixed.

Is see that onUnreadMessageInView returns immediately if window is in focus? How should the messages ever be marked as read?

@nicodh
Copy link
Member

nicodh commented Feb 16, 2025

Btw. strange that this never was reported so far as bug. It exists at least since 1.52.0.

It is pretty obvious that the badge in the chatlist still shows the number of unread messages even if you scroll to the buttom

@WofWca
Copy link
Collaborator Author

WofWca commented Feb 16, 2025

onUnreadMessageInView returns immediately if window is in focus?

It's the opposite

const onUnreadMessageInView: IntersectionObserverCallback = entries => {
if (!chat) return
// Don't mark messages as read if window is not focused
if (document.hasFocus() === false) return

I tested this and the behaviour is the same as in main, so the bug is not fixed.

Does the "Message info" dialog show that the last message is read?
I re-tested this again, and for me this does fix the bug.
Maybe the issue is that the message isn't actually marked as "read"?

@nicodh
Copy link
Member

nicodh commented Feb 16, 2025

onUnreadMessageInView returns immediately if window is in focus?

It's the opposite

Argh - ok since I was in the debugger the chat window has no focus anymore. So now I set a debug break point in MessageList.tsx line 198
BackendRemote.rpc
.markseenMsgs(accountId, messageIdsToMarkAsRead)
.then(debouncedUpdateBadgeCounter)

But that was not triggered when scrolling down and thus the counter doesn't get updated. (even without brek point of course)

Interestingly it gets updated as soon as I click somewhere in the chat window or the composer. So maybe when switching to the Deltachat Window and just scroll it does not really focus the chat window?

@nicodh
Copy link
Member

nicodh commented Feb 16, 2025

screencast6.mp4

The interruption was the debugger at markseenMsgs

@WofWca
Copy link
Collaborator Author

WofWca commented Feb 16, 2025

Is the window focused in the first half of the video? If not, I'd say it's expected.

@nicodh
Copy link
Member

nicodh commented Feb 16, 2025

Is the window focused in the first half of the video? If not, I'd say it's expected.

The chat is open and I switched from another app back to deltachat. See there are new messages and scroll down. The jumpDown button disappears but the chat list item still shows the counter and markRead is not triggered. So I scrolled to bottom see all messages but it needs another action to trigger the focus? The scrolling should be enough for triggering. So maybe we need another condition. Is it possible to scroll a window without having focus?
I scroll with topuchpad not by clicking on the scrollbar

@WofWca
Copy link
Collaborator Author

WofWca commented Feb 16, 2025

Is it possible to scroll a window without having focus?

Yes, e.g. if you have two windows side-by-side.

The chat is open and I switched from another app back to deltachat.

In this case yeah, sounds like a bug. It's not reproducible on Windows. There it's enough to just Alt + Tab back to the Delta Chat window, then scrolling with the scroll wheel does mark messages as read.

Either way, this MR is not relevant to this.

Copy link
Member

@nicodh nicodh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The observed behaviour was caused by a special case - focus was not triggered in a scrolled window, but the fix solves the bug, that the counter is not correct updated

@WofWca
Copy link
Collaborator Author

WofWca commented Feb 17, 2025

scrolling with the scrollbar

I meant to say "with the scroll wheel"

@WofWca WofWca merged commit e700817 into main Feb 17, 2025
5 of 8 checks passed
@WofWca WofWca deleted the wofwca/fix-jump-down-counter-2 branch February 17, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants