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

channels: more accurate unread counts #3119

Merged
merged 22 commits into from
Dec 19, 2023
Merged

channels: more accurate unread counts #3119

merged 22 commits into from
Dec 19, 2023

Conversation

Fang-
Copy link
Member

@Fang- Fang- commented Dec 11, 2023

The improvement here is two-fold:

First, we no longer recalculate the "most recent content" timestamp when marking a channel as read. Instead, we simply reuse the .recency which we were already tracking anyway. I don't remember why we thought we had to re-derive that on the spot. (2928b4b)

Second, we update the $unread type to provide, in addition to the total unread count, sub-counts for each context in which unreads may exist: top-level and within reply threads. (be58f62)

Draft because this does not yet include the frontend updates required for the latter change. cc @patosullivan

For LAND-1393 and LAND-1394.
Fixes LAND-1412

Instead of re-deriving recency based on the unread threads. That
re-deriving was causing inaccurate results for whatever reason, and was
100% going to be slower than just reading the recency.

Fixes LAND-1393.
In addition to providing a total "count", we now also provide an
individual count for top-level "unread", as well as each "threads"
entry. This way, clients may display accurate unread counts for each
context.

Partially fixes LAND-1394, frontend changes still pending.
Fang- and others added 10 commits December 13, 2023 21:25
Otherwise we run a small risk of ordering shenanigans.
be58f62 updated the unread types for channels to provide per-context
counts. Here, we do the same for chats.
We now have access to per-context unread counts. We make sure to include
those in the DateDividers.
After review, we have concluded one of these functions can go entirely
(it is unused), and the TODO for the other is invalid: the response
still depends on ordering of the respective unreads.
@Fang- Fang- marked this pull request as ready for review December 14, 2023 17:35
Copy link
Collaborator

@midsum-salrux midsum-salrux left a comment

Choose a reason for hiding this comment

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

LGTM

(lot:on-v-replies:c replies.u.u.parent `last-read.remark.channel ~)
|= [tim=time reply=(unit v-reply:c)]
?& ?=(^ reply)
!=(author.u.reply our.bowl)
==
:- (add sum (lent unreads))
=/ count=@ud (lent unreads)
Copy link
Collaborator

Choose a reason for hiding this comment

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

NB: I don't like reusing the name here but it was already doing that for unreads.

@Fang-
Copy link
Member Author

Fang- commented Dec 14, 2023

Actually the top-level count (not the total) provided by this is inaccurate for cases where both a top-level message with replies is below the top-level marker: in that case the replies should be included in the top-level count, but aren't.

Fixing...

Edit: Apparently the current behavior is desired. Not fixing!

…, rename unread method to make its purpose clearer and handle empty unreads properly without relying on separate checks at callee site
…when the component unmounts instead of any time the dependencies update
… an instance of simplified code we may want to revisit
Copy link

linear bot commented Dec 18, 2023

@mrozanski
Copy link
Contributor

Label do not merge added only because we're approaching a long holiday break, and we may prefer to merge once everyone is back to manage risks. (I'm open to reviewing this decision)

Copy link
Member

@arthyn arthyn left a comment

Choose a reason for hiding this comment

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

lgtm lets test on binnec

Comment on lines +352 to 353
// TODO: chesterton's fence, but why execute a read here?
useChatStore.getState().read(whom);
Copy link
Member

Choose a reason for hiding this comment

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

holdover from bad behavior during rewrite

@arthyn arthyn merged commit bd1aa64 into develop Dec 19, 2023
1 check passed
@arthyn arthyn deleted the m/unreads-again branch December 19, 2023 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants