-
Notifications
You must be signed in to change notification settings - Fork 17
SHARD-2140: add unstakeCooldown logic #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
const cooldown = stakeInfo.unstakeInterval - (Date.now() - lastUnstakeTime) | ||
return cooldown > 0 ? cooldown : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Ensure that stakeInfo.unstakeInterval
and lastUnstakeTime
are valid numbers before performing arithmetic operations to prevent potential runtime errors. [possible issue, importance: 7]
const cooldown = stakeInfo.unstakeInterval - (Date.now() - lastUnstakeTime) | |
return cooldown > 0 ? cooldown : 0 | |
const cooldown = (typeof stakeInfo.unstakeInterval === 'number' && typeof lastUnstakeTime === 'number') | |
? stakeInfo.unstakeInterval - (Date.now() - lastUnstakeTime) | |
: 0; | |
return cooldown > 0 ? cooldown : 0; |
window.addEventListener('storage', handleStorageChange) | ||
return () => window.removeEventListener('storage', handleStorageChange) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Verify that handleStorageChange
is properly defined and handles all potential edge cases, such as null or undefined values for e.newValue
. [general, importance: 6]
window.addEventListener('storage', handleStorageChange) | |
return () => window.removeEventListener('storage', handleStorageChange) | |
window.addEventListener('storage', handleStorageChange) | |
return () => window.removeEventListener('storage', handleStorageChange) | |
function handleStorageChange(e: StorageEvent) { | |
if (e.key === Constants.UNSTAKE_COOLDOWN_KEY) { | |
const newValue = e.newValue ? parseInt(e.newValue) : 0; | |
if (!isNaN(newValue)) { | |
setLastUnstake(newValue); | |
} | |
} | |
} |
PR Type
enhancement, bug fix
Description
Implemented unstake cooldown logic in
StakeDisplay
.Added
unstakeInterval
toAccountStakeInfo
model.Introduced
Constants
for managing local storage keys.Enhanced tooltip logic for unstake button.
Changes walkthrough 📝
StakeDisplay.tsx
Implement unstake cooldown and enhance tooltips
components/molecules/StakeDisplay.tsx
Constants
for local storage management.useUnstake.ts
Add unstake cooldown storage logic
hooks/useUnstake.ts
Constants
for local storage key management.account-stake-info.ts
Extend AccountStakeInfo with unstakeInterval
model/account-stake-info.ts
unstakeInterval
property to interface.useStake.ts
Clean up unused imports
hooks/useStake.ts
constants.ts
Add Constants for local storage keys
utils/constants.ts
Constants
object for key management.