Skip to content

Commit

Permalink
address TODO around clearing unread flags when closing a 'my pinboard…
Browse files Browse the repository at this point in the history
…' which is also a group pinboard and might have its own unread there
  • Loading branch information
twrichards committed Dec 2, 2024
1 parent aa6918e commit 2365500
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions client/src/globalState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,7 @@ export const GlobalStateProvider = ({
}
setSelectedPinboardId(null);
setError(pinboardIdToClose, undefined);
//TODO probably need to check if pinboard is also in group pinboards, so we don't lose an unread on there
setUnreadFlag(pinboardIdToClose)(undefined);
setUnreadFlag(pinboardIdToClose)(undefined); // note that panel.tsx detects this and reinstates any hasUnread from the group pinboards
};

useEffect(() => {
Expand Down
10 changes: 10 additions & 0 deletions client/src/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const Panel = ({
activeTab,
setActiveTab,
boundedPositionTranslation,
unreadFlags,
setUnreadFlag,
totalItemsReceivedViaSubscription,
} = useGlobalStateContext();
Expand Down Expand Up @@ -109,6 +110,15 @@ export const Panel = ({
[groupPinboardIdsQuery.data]
);

useEffect(() => {
// ensure that if ever the pinboard is closed manually, the hasUnread from the group pinboards becomes the value
groupPinboardIdsWithClaimCounts.forEach(
({ pinboardId, hasUnread }) =>
unreadFlags[pinboardId] === undefined &&
setUnreadFlag(pinboardId)(hasUnread)
);
}, [unreadFlags]);

useEffect(() => {
groupPinboardIdsWithClaimCounts.forEach(({ pinboardId, hasUnread }) =>
setUnreadFlag(pinboardId)(hasUnread)
Expand Down

0 comments on commit 2365500

Please sign in to comment.