diff --git a/client/src/fronts/frontsIntegration.tsx b/client/src/fronts/frontsIntegration.tsx index 4eb97a01..92b66a8f 100644 --- a/client/src/fronts/frontsIntegration.tsx +++ b/client/src/fronts/frontsIntegration.tsx @@ -30,8 +30,11 @@ export const FrontsIntegration = ({ [frontsPinboardElements] ); - const { setError, totalItemsReceivedViaSubscription } = - useGlobalStateContext(); + const { + setError, + totalItemsReceivedViaSubscription, + totalOfMyOwnOnSeenItemsReceivedViaSubscription, + } = useGlobalStateContext(); const apolloClient = useApolloClient(); @@ -79,7 +82,10 @@ export const FrontsIntegration = ({ useEffect(() => { itemCountsQuery.refetch(); - }, [totalItemsReceivedViaSubscription]); + }, [ + totalItemsReceivedViaSubscription, + totalOfMyOwnOnSeenItemsReceivedViaSubscription, + ]); useEffect(() => { itemCountsQuery.data?.getItemCounts && diff --git a/client/src/globalState.tsx b/client/src/globalState.tsx index e750d13b..58c9c259 100644 --- a/client/src/globalState.tsx +++ b/client/src/globalState.tsx @@ -68,6 +68,7 @@ interface GlobalStateContextShape { allSubscriptionClaimedItems: Item[]; // both the updated 'claimed' item and the new 'claim' item allSubscriptionOnSeenItems: LastItemSeenByUser[]; totalItemsReceivedViaSubscription: number; + totalOfMyOwnOnSeenItemsReceivedViaSubscription: number; payloadToBeSent: PayloadAndType | null; setPayloadToBeSent: (newPayloadToBeSent: PayloadAndType | null) => void; @@ -341,6 +342,11 @@ export const GlobalStateProvider = ({ }, }); + const [ + totalOfMyOwnOnSeenItemsReceivedViaSubscription, + setTotalOfMyOwnOnSeenItemsReceivedViaSubscription, + ] = useState(0); + const [allSubscriptionOnSeenItems, setAllSubscriptionOnSeenItems] = useState< LastItemSeenByUser[] >([]); @@ -359,6 +365,9 @@ export const GlobalStateProvider = ({ newLastItemSeenByUser, ]); } + if (newLastItemSeenByUser.userEmail === userEmail) { + setTotalOfMyOwnOnSeenItemsReceivedViaSubscription((prev) => prev + 1); + } }, }); @@ -688,6 +697,7 @@ export const GlobalStateProvider = ({ allSubscriptionClaimedItems, allSubscriptionOnSeenItems, totalItemsReceivedViaSubscription, + totalOfMyOwnOnSeenItemsReceivedViaSubscription, payloadToBeSent, setPayloadToBeSent, diff --git a/client/src/inline/inlineMode.tsx b/client/src/inline/inlineMode.tsx index 3e8a2511..51a73918 100644 --- a/client/src/inline/inlineMode.tsx +++ b/client/src/inline/inlineMode.tsx @@ -38,7 +38,10 @@ export const InlineMode = ({ maybeInlineSelectedPinboardId, setMaybeInlineSelectedPinboardId, }: InlineModeProps) => { - const { totalItemsReceivedViaSubscription } = useGlobalStateContext(); + const { + totalItemsReceivedViaSubscription, + totalOfMyOwnOnSeenItemsReceivedViaSubscription, + } = useGlobalStateContext(); const pinboardArea = useMemo( () => document.getElementById("pinboard-area"), @@ -82,7 +85,11 @@ export const InlineMode = ({ ), }); } - }, [workflowTitleElementLookup, totalItemsReceivedViaSubscription]); + }, [ + workflowTitleElementLookup, + totalItemsReceivedViaSubscription, + totalOfMyOwnOnSeenItemsReceivedViaSubscription, + ]); const maybeSelectedNode = maybeInlineSelectedPinboardId && diff --git a/client/src/panel.tsx b/client/src/panel.tsx index 0f10beaf..c7f57844 100644 --- a/client/src/panel.tsx +++ b/client/src/panel.tsx @@ -69,6 +69,7 @@ export const Panel = ({ unreadFlags, setUnreadFlag, totalItemsReceivedViaSubscription, + totalOfMyOwnOnSeenItemsReceivedViaSubscription, } = useGlobalStateContext(); const tourProgress = useTourProgress(); @@ -100,7 +101,10 @@ export const Panel = ({ useEffect(() => { groupPinboardIdsQuery.refetch(); - }, [totalItemsReceivedViaSubscription]); + }, [ + totalItemsReceivedViaSubscription, + totalOfMyOwnOnSeenItemsReceivedViaSubscription, + ]); const groupPinboardIdsWithClaimCounts: PinboardIdWithClaimCounts[] = useMemo( () =>