| | |
| | | [currentTime], |
| | | ) |
| | | |
| | | const countdownTimeout = useRef<number>(undefined) |
| | | const countdownTimeout = useRef<NodeJS.Timeout>() |
| | | const clearCountdown = useCallback(() => { |
| | | if (countdownTimeout.current) { |
| | | window.clearTimeout(countdownTimeout.current) |
| | | clearTimeout(countdownTimeout.current) |
| | | countdownTimeout.current = undefined |
| | | } |
| | | }, []) |
| | |
| | | |
| | | const countdown = useCallback(() => { |
| | | clearCountdown() |
| | | countdownTimeout.current = window.setTimeout(() => { |
| | | countdownTimeout.current = setTimeout(() => { |
| | | const now = Date.now() |
| | | if (now <= targetTime.current) { |
| | | setCurrentTime(Date.now()) |
| | |
| | | return displayTime |
| | | ? ( |
| | | <Tooltip popupContent={t('common.modelProvider.apiKeyRateLimit', { seconds: displayTime })}> |
| | | <SimplePieChart percentage={Math.round(displayTime / 60 * 100)} className='h-3 w-3' /> |
| | | <SimplePieChart percentage={Math.round(displayTime / 60 * 100)} className='w-3 h-3' /> |
| | | </Tooltip> |
| | | ) |
| | | : null |