Skip to content

Commit

Permalink
Revert "Merge pull request #3638 from tloncorp/lb/staging-to-dev-2"
Browse files Browse the repository at this point in the history
This reverts commit 19ba44f, reversing
changes made to badbdfa.
  • Loading branch information
latter-bolden committed Jun 18, 2024
1 parent 3f79f92 commit 7a448c5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 46 deletions.
4 changes: 0 additions & 4 deletions apps/tlon-web/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,6 @@ const Sidebar = React.memo(() => {
);
});

Sidebar.displayName = 'Sidebar';

const SidebarTopSection = React.memo(
({
title,
Expand Down Expand Up @@ -292,6 +290,4 @@ const SidebarTopSection = React.memo(
}
);

SidebarTopSection.displayName = 'SidebarTopSection';

export default Sidebar;
45 changes: 3 additions & 42 deletions apps/tlon-web/src/state/unreads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,43 +105,15 @@ function sumChildren(
return acc;
}

const {
count: grandChildCount,
notify: grandChildNotify,
status: grandChildStatus,
} = Object.entries(unreads[key].children || {}).reduce(
(grandAcc, [grandKey, grandChild]) => {
const grandChildStatus = unreads[grandKey]?.status;
const grandChildNotify = unreads[grandKey]?.notify;

return {
count: grandChildNotify
? grandAcc.count + grandChild.count
: grandAcc.count,
notify: grandAcc.notify || grandChildNotify,
status: grandChildNotify
? combineStatus(childStatus, grandChildStatus || 'read')
: grandAcc.status,
};
},
{
count: 0,
notify: false,
status: 'read',
}
);

if (childStatus === 'unread' || grandChildStatus === 'unread') {
if (childStatus === 'unread') {
status = 'unread';
} else if (childStatus === 'seen' && status === 'read') {
status = 'seen';
}

return {
count: !sumCounts
? acc.count
: acc.count + (child.unread?.count || 0) + grandChildCount,
notify: acc.notify || Boolean(child.notify) || grandChildNotify,
count: !sumCounts ? acc.count : acc.count + (child.unread?.count || 0),
notify: acc.notify || Boolean(child.notify),
status,
};
},
Expand Down Expand Up @@ -300,17 +272,6 @@ export const useUnreadsStore = create<UnreadsStore>((set, get) => ({
? childSrc.parents
: [...childSrc.parents, key],
};

const parent = draft.sources[key];
const childSummary = summaries[child];

draft.sources[key] = {
...parent,
children: {
...parent.children,
[child]: childSummary,
},
};
});
});
})
Expand Down

0 comments on commit 7a448c5

Please sign in to comment.