Skip to content

Commit

Permalink
Merge pull request #3647 from tloncorp/hm/fix-unreads-pt-77
Browse files Browse the repository at this point in the history
unreads: fix missing counts, missing group dots, and inability to clear dm threads
  • Loading branch information
arthyn authored Jun 21, 2024
2 parents b6cff4e + e802e8e commit 0b2e92d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/tlon-web/src/groups/GroupSidebar/ChannelList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ const ChannelList = React.memo(({ paddingTop }: { paddingTop?: number }) => {
actions={
isChannelUnread(nest) ? (
<UnreadIndicator
count={getUnread(nest)?.count || 0}
count={getUnread(nest)?.combined.count || 0}
notify={getUnread(nest)?.combined.notify}
/>
) : null
Expand Down
14 changes: 9 additions & 5 deletions apps/tlon-web/src/state/unreads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,18 @@ function sumChildren(
const { count, notify, status } = Object.entries(
children
).reduce<ShortSummary>(
(acc, [key, child]) => {
(acc, [key, summary]) => {
let status = acc.status;
const childStatus = unreads[key]?.status;
const child = unreads[key];
const childCount = child?.combined.count || summary.unread?.count || 0;
const childNotify =
child?.combined.notify || Boolean(summary.unread?.notify);
const childStatus = child?.combined.status;

// if we don't care about summing counts then we can skip aggregating
// but if any child is notify then we need to take into account it's
// status and notify values
if (!(sumCounts || child.notify)) {
if (!(sumCounts || childNotify)) {
return acc;
}

Expand All @@ -112,8 +116,8 @@ function sumChildren(
}

return {
count: !sumCounts ? acc.count : acc.count + (child.unread?.count || 0),
notify: acc.notify || Boolean(child.notify),
count: acc.count + (childCount || 0),
notify: acc.notify || Boolean(childNotify),
status,
};
},
Expand Down
4 changes: 2 additions & 2 deletions desk/app/chat.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@
~
=? cor (want-hark %to-us)
(emit (pass-yarn new-yarn))
=/ concern [%post [. q]:p.diff.delta]
=/ concern [%post p.diff.delta now.bowl]
=/ mention (was-mentioned:utils content.memo our.bowl)
=. cu-core (cu-activity concern content.memo mention)
(cu-give-writs-diff diff.delta)
Expand Down Expand Up @@ -1347,7 +1347,7 @@
=? cor (want-hark %to-us)
(emit (pass-yarn new-yarn))
=/ top-con [. q]:p.diff.delta
=/ concern [%reply [. q]:id.q.diff.delta top-con]
=/ concern [%reply [id.q.diff.delta now.bowl] top-con]
=/ mention (was-mentioned:utils content.memo our.bowl)
=. cu-core (cu-activity concern content.memo mention)
(cu-give-writs-diff diff.delta)
Expand Down

0 comments on commit 0b2e92d

Please sign in to comment.