Skip to content

Commit

Permalink
[fronts integration] handle when there are no counts for a pinboard, …
Browse files Browse the repository at this point in the history
…because there are no messages on that pinboard
  • Loading branch information
twrichards committed Oct 15, 2024
1 parent 9c6828e commit 3e2fc4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 5 additions & 5 deletions client/src/fronts/frontsIntegration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ export const FrontsIntegration = ({
interface ItemCountsLookup {
[pinboardId: string]: PinboardIdWithItemCounts;
}
const [itemCountsLookup, setItemCountsLookup] = useState(
{} as ItemCountsLookup
);
const [maybeItemCountsLookup, setMaybeItemCountsLookup] = useState();
useEffect(() => {
const pinboardIds = Object.values(pathToPinboardDataMap).map(
({ id }) => id
Expand All @@ -82,7 +80,7 @@ export const FrontsIntegration = ({
})
.then(({ data }) => {
data?.getItemCounts &&
setItemCountsLookup(
setMaybeItemCountsLookup(
data.getItemCounts.reduce(
(
acc: ItemCountsLookup,
Expand All @@ -105,9 +103,11 @@ export const FrontsIntegration = ({
ReactDOM.createPortal(
<FrontsPinboardArticleButton
maybePinboardData={pathToPinboardDataMap[path]}
hasCountsLoaded={!!maybeItemCountsLookup}
maybeItemCounts={
pathToPinboardDataMap[path] &&
itemCountsLookup[pathToPinboardDataMap[path].id]
maybeItemCountsLookup &&
maybeItemCountsLookup[pathToPinboardDataMap[path].id]
}
withDraggableThumbsOfRatio={
htmlElementToMountInto.dataset.withDraggableThumbsOfRatio
Expand Down
5 changes: 4 additions & 1 deletion client/src/fronts/frontsPinboardArticleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ interface FrontsPinboardArticleButtonProps {
maybePinboardData: PinboardData | undefined;
maybeItemCounts: PinboardIdWithItemCounts | undefined;
withDraggableThumbsOfRatio: string | undefined;
hasCountsLoaded: boolean;
}

export const FrontsPinboardArticleButton = ({
maybePinboardData,
maybeItemCounts,
withDraggableThumbsOfRatio,
hasCountsLoaded,
}: FrontsPinboardArticleButtonProps) => {
const { setIsExpanded, openPinboard } = useGlobalStateContext();

Expand Down Expand Up @@ -90,7 +92,8 @@ export const FrontsPinboardArticleButton = ({
}}
>
{!maybePinboardData && "Not tracked in workflow"}
{maybePinboardData && !maybeItemCounts && <em>loading...</em>}
{maybePinboardData && !hasCountsLoaded && <em>loading...</em>}
{maybePinboardData && hasCountsLoaded && !maybeItemCounts && "0 items"}
{maybeItemCounts && (
<>
{
Expand Down

0 comments on commit 3e2fc4c

Please sign in to comment.