Skip to content

Commit

Permalink
update: don't wait for close if the account has seen the modal
Browse files Browse the repository at this point in the history
  • Loading branch information
PetromirDev committed Aug 8, 2024
1 parent e663287 commit f6c7f3e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ import styles from './ExtensionInviteCodeModal.module.scss'
const CAN_CLOSE_AFTER_MS = 5400

const ExtensionInviteCodeModal = ({ inviteCode, waitForClose = true }) => {
const { onHideModal } = useModals()
const { hideModal } = useModals()
const { addToast } = useToasts()
const [remainingTime, setRemainingTime] = useState(CAN_CLOSE_AFTER_MS)
const [canClose, setCanClose] = useState(!waitForClose)

const handleCloseModal = useCallback(() => {
if (!canClose) return
onHideModal()
}, [canClose, onHideModal])

hideModal()
}, [canClose, hideModal])

useEffect(() => {
const startingTime = Date.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ $min-modal-height: 34.375rem;
color: #fff;
font-size: 0.875rem;
opacity: 0.6;
user-select: none;
}
.closeIcon {
cursor: pointer;
Expand Down
18 changes: 16 additions & 2 deletions src/components/Wallet/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export default function Wallet(props) {
key: 'dAppsAdvancedMode',
defaultValue: []
})
const [extensionInviteCodeModalSeenBy, setExtensionInviteCodeModalSeenBy] = useLocalStorage({
key: 'extensionInviteCodeModalSeenBy',
defaultValue: []
})

const routes = [
{
Expand Down Expand Up @@ -257,7 +261,16 @@ export default function Wallet(props) {

if (!key || used || rewardsAccountAddr !== account.id) return

showModal(<ExtensionInviteCodeModal inviteCode={key} />, { disableClose: true })
const isSeen = extensionInviteCodeModalSeenBy.includes(account.id)

if (!isSeen) {
setExtensionInviteCodeModalSeenBy((prev) => [...prev, account.id])
}

showModal(<ExtensionInviteCodeModal inviteCode={key} waitForClose={!isSeen} />, {
disableClose: !isSeen
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
props.accounts,
props.relayerURL,
Expand All @@ -271,7 +284,8 @@ export default function Wallet(props) {
isClipboardGranted,
isNoticationsGranted,
modalHidden,
showModal
showModal,
setExtensionInviteCodeModalSeenBy
])

useEffect(() => handleDisplayInitialModal(), [handleDisplayInitialModal])
Expand Down

0 comments on commit f6c7f3e

Please sign in to comment.