Skip to content

Commit c7fec39

Browse files
authored
Merge pull request #189 from bitovi/fix-stale-data-in-voter-tooltip
2 parents fd27dee + b03c48f commit c7fec39

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

packages/client/src/components/common/ReactionStatistics/ReactionStatistics.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export function ReactionStatistics({
88
upvoters,
99
downvotes = 0,
1010
downvoters,
11+
isPending = false,
1112
onUpvote,
1213
onDownvote,
1314
className
@@ -20,6 +21,7 @@ export function ReactionStatistics({
2021
showCount={userVote === 'up'}
2122
count={upvotes}
2223
voters={upvoters}
24+
isPending={isPending}
2325
onClick={onUpvote}
2426
/>
2527
<VoteButton
@@ -28,6 +30,7 @@ export function ReactionStatistics({
2830
showCount={userVote === 'down'}
2931
count={downvotes}
3032
voters={downvoters}
33+
isPending={isPending}
3134
onClick={onDownvote}
3235
/>
3336
</div>

packages/client/src/components/common/ReactionStatistics/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export interface ReactionStatisticsProps {
3737
*/
3838
onDownvote?: () => void;
3939

40+
/**
41+
* Whether a mutation is pending
42+
*/
43+
isPending?: boolean;
44+
4045
/**
4146
* Additional CSS classes
4247
*/

packages/client/src/components/common/RelatedCasesAccordion/RelatedCasesAccordion.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { formatCaseNumber } from '@carton/shared';
1+
import { formatCaseNumber } from '@carton/shared/client';
22
import { RelationshipManagerAccordion } from '../RelationshipManagerAccordion/RelationshipManagerAccordion';
33

44
interface RelatedCasesAccordionProps {

packages/client/src/components/common/VoteButton/VoteButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export function VoteButton({
99
showCount = true,
1010
count,
1111
voters,
12+
isPending = false,
1213
onClick,
1314
className,
1415
}: VoteButtonProps) {
@@ -43,7 +44,8 @@ export function VoteButton({
4344
);
4445

4546
// If voters are provided and there's a count, wrap with tooltip
46-
if (voters && voters.length > 0 && count !== undefined && count > 0) {
47+
// Skip tooltip if mutation is pending to avoid showing stale data
48+
if (voters && voters.length > 0 && count !== undefined && count > 0 && !isPending) {
4749
const displayVoters = voters.slice(0, 3);
4850
const remainingCount = voters.length - 3;
4951

packages/client/src/components/common/VoteButton/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ export interface VoteButtonProps {
3131
*/
3232
voters?: string[];
3333

34+
/**
35+
* Whether a mutation is pending
36+
*/
37+
isPending?: boolean;
38+
3439
/**
3540
* Click handler for voting interaction
3641
*/

0 commit comments

Comments
 (0)