-
-
Notifications
You must be signed in to change notification settings - Fork 268
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 handling un-read count for un-indexed messages. #398
base: main
Are you sure you want to change the base?
Conversation
5cc71b5
to
6214b85
Compare
Thanks @sumanthvrao. I just checked the response we receive from the server and it includes |
Great. Will check it out 👍 ! |
5a8a330
to
90b427e
Compare
Updated this 👍 @neiljp The first 3 commits here are quite independent, there were also some of the changes we were discussing in #393 . This includes, a small indentation change (commit 1), renaming The later commits (Last 2) are sort of techniques I came up with, which works for now (regardless of them being the best solution). I would love to have your feedback on them. |
90b427e
to
61002eb
Compare
de9eadc
to
611ff86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sumanthvrao While I've left some comments, I think this may be simpler if we associated the 'decrease' (ie. transfer from unindexed to indexed) with just being called whenever we successfully get_messages
?
That would make it easier to keep the state in the Model
and maybe even remove the need for at least one of the extra methods - and maybe rename the other?
zulipterminal/ui_tools/views.py
Outdated
@@ -87,6 +87,7 @@ def load_new_messages(self, anchor: int) -> None: | |||
else: | |||
last_message = None | |||
|
|||
self.model.decrease_unindexed_message_count(new_ids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary for load_old_messages
, too, I suspect?
def increase_unindexed_message_count(self, | ||
message: Dict[str, Any]) -> None: | ||
unindexed_messages[message['id']] = message | ||
set_count([message['id']], self.controller, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to check for whether the message is already marked as read?
zulipterminal/helper.py
Outdated
@@ -39,6 +39,7 @@ | |||
all_starred=set(), | |||
) | |||
|
|||
unindexed_messages = dict() # type: Dict[int, Any] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand why you might want to avoid having this in the Index itself, but I'm unconvinced it should be a global variable.
For now, placing this in the model might be simpler?
611ff86
to
5fefd8f
Compare
For narrows, in which not all the messages have been fetched yet, when a new message arrives, it cannot be appended to the view (index). However, even its unread count does not increase. To avoid this, we maintain an un-indexed message collection. When, a new message arrives, we add its id to the un-indexed collection and increment its count. When we narrow to a stream, or load_new_messages, narrow_to_user, etc, we pop the fetched message which are un-indexed as they are now indexed. The indexed and un-indexed collections are mutually exclusive to each other. Tests amended. Fixes: zulip#395
5fefd8f
to
8e9be70
Compare
Heads up @sumanthvrao, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
This PR is a step in the direction of fixing #395.
TODO:
Add tests