Skip to content

Commit

Permalink
fix: logic to show mnemonic backup reminder when no mnemonics present (
Browse files Browse the repository at this point in the history
  • Loading branch information
chidg authored Oct 4, 2023
1 parent 796eb2b commit 32adcf5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "extension",
"version": "1.19.0",
"version": "1.19.1",
"private": true,
"license": "GPL-3.0-or-later",
"dependencies": {
Expand Down
21 changes: 17 additions & 4 deletions apps/extension/src/ui/hooks/useMnemonicBackup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,30 @@ const useMnemonicBackup = () => {
const mnemonics = useMnemonics()
const location = useLocation()

const allBackedUp = useMemo(() => mnemonics.every((mnemonic) => mnemonic.confirmed), [mnemonics])
const anyBackedUp = useMemo(() => mnemonics.some((mnemonic) => mnemonic.confirmed), [mnemonics])
const hasMnemonics = useMemo(() => mnemonics.length > 0, [mnemonics])

const allBackedUp = useMemo(
() => !hasMnemonics || mnemonics.every((mnemonic) => mnemonic.confirmed),
[mnemonics, hasMnemonics]
)
const anyBackedUp = useMemo(
() => hasMnemonics && mnemonics.some((mnemonic) => mnemonic.confirmed),
[mnemonics, hasMnemonics]
)

const isSnoozed = useMemo(() => {
return Boolean(hideBackupWarningUntil && hideBackupWarningUntil > Date.now() && !anyBackedUp)
}, [hideBackupWarningUntil, anyBackedUp])

// whether we must show the big backup warning modal
const showBackupWarning = useMemo(
() => !isSnoozed && !anyBackedUp && hasFunds && location.pathname !== "/settings/mnemonics",
[isSnoozed, anyBackedUp, hasFunds, location.pathname]
() =>
!isSnoozed &&
hasMnemonics &&
!anyBackedUp &&
hasFunds &&
location.pathname !== "/settings/mnemonics",
[isSnoozed, anyBackedUp, hasMnemonics, hasFunds, location.pathname]
)

// whether we must show the small backup warning notification in dashboard
Expand Down

0 comments on commit 32adcf5

Please sign in to comment.