Skip to content

Commit

Permalink
fix(canary-position): upadte canary position for when canary position…
Browse files Browse the repository at this point in the history
… doesn't exist
  • Loading branch information
jjBlockchain committed Jul 9, 2024
1 parent ac95393 commit ff2d5d2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/blockchain-wallet-v4-frontend/src/scenes/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,23 @@ const App = ({
const canaryPositionString = localStorage.getItem('canary_position')
let canaryPosition = Number(canaryPositionString)

const setCanaryPosition = () => {
canaryPosition = Math.floor(Math.random() * 101)
localStorage.setItem('canary_position', `${canaryPosition}`)
}

// IF THE CANARY POSITION DOES NOT EXIST, GENERATE A NEW ONE.
if (canaryPositionString === null || canaryPositionString === undefined) setCanaryPosition()

// MAKE SURE THE CANARY POSITION IS VALID, IF NOT, UPDATE THE VALUE.
if (Number.isNaN(canaryPosition)) {
// eslint-disable-next-line
console.log(
`[ROUTING_DEBUG]: canary_position was NaN, Raw: ${canaryPositionString}, Setting a new canary_position.`
)
canaryPosition = Math.floor(Math.random() * 101)
setCanaryPosition()
// eslint-disable-next-line
console.log(`[ROUTING_DEBUG]: Set canary_position to ${canaryPosition}`)
localStorage.set('canary_position', `${canaryPosition}`)
}

// IF THE USER HAS REQUESTED TO STAY IN V4.
Expand Down

0 comments on commit ff2d5d2

Please sign in to comment.