Skip to content

Commit

Permalink
Merge pull request #6423 from blockchain/feat/opt-out-date-GROWUX-4920
Browse files Browse the repository at this point in the history
feat(opt-out-date): add opt out date to localStorage
  • Loading branch information
jjBlockchain authored Aug 1, 2024
2 parents 6505d51 + b36d665 commit c9841ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ const SuperAppLink = () => {
const hasSuperAppAccess = localStorage.getItem('wallet_v5_ui_available') === 'true'

const handleClick = () => {
const optOutDate = localStorage.getItem('opt_out_date')

if (optOutDate) {
localStorage.removeItem('opt_out_date')
}
localStorage.setItem('opt_out_wallet_v5_ui', 'false')

window.location.reload()
}

Expand Down
8 changes: 7 additions & 1 deletion packages/blockchain-wallet-v4-frontend/src/scenes/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ const App = ({
useEffect(() => {
// Used to get cached values from old implementation, if they exist.
const cookies = new Cookies()
const optOut = localStorage.getItem('opt_out_wallet_v5_ui')
const optOutDate = localStorage.getItem('opt_out_date')
const cache = {
canary_position: cookies.get('canary_position'),
opt_out_wallet_v5_ui: cookies.get('opt_out_wallet_v5_ui')
Expand All @@ -123,10 +125,14 @@ const App = ({
}

// Update localStorage cache with current values, if exists.
if (localStorage.getItem('opt_out_wallet_v5_ui') === null && cache.opt_out_wallet_v5_ui) {
if (optOut === null && cache.opt_out_wallet_v5_ui) {
localStorage.setItem('opt_out_wallet_v5_ui', JSON.stringify(cache.opt_out_wallet_v5_ui))
}

if (optOut && optOutDate === null) {
localStorage.setItem('opt_out_date', new Date().toISOString())
}

// OBTAIN THE THRESHOLD - STATICALLY SET, DECIDED BY TEAM.
const THRESHOLD = 30

Expand Down

0 comments on commit c9841ff

Please sign in to comment.