- Created useIsRateLimited() hook to check rate limit state - Updated CommentSection submit button to disable when rate limited - Updated LikeButton to disable when rate limited - Updated PlaylistForm submit button to disable when rate limited - Updated ChatInput send button to disable when rate limited - Updated UploadModal upload button to disable when rate limited - All buttons check isLimited from rate limit store - Hook uses Zustand selector for efficient re-renders - Pattern established for future mutation buttons - Action 5.4.1.4 complete
24 lines
594 B
TypeScript
24 lines
594 B
TypeScript
/**
|
|
* Hook to check if user is currently rate limited
|
|
* Action 5.4.1.4: Disable buttons when rate limited
|
|
*/
|
|
|
|
import { useRateLimitStore } from '@/stores/rateLimit';
|
|
|
|
/**
|
|
* Hook to check if the user is currently rate limited
|
|
*
|
|
* @returns {boolean} True if user is rate limited, false otherwise
|
|
*
|
|
* @example
|
|
* ```tsx
|
|
* const isRateLimited = useIsRateLimited();
|
|
* <Button disabled={isSubmitting || isRateLimited}>
|
|
* Submit
|
|
* </Button>
|
|
* ```
|
|
*/
|
|
export function useIsRateLimited(): boolean {
|
|
const isLimited = useRateLimitStore((state) => state.isLimited);
|
|
return isLimited;
|
|
}
|