Skip to content

Commit

Permalink
chore: clear gacha alert if switching to another account
Browse files Browse the repository at this point in the history
  • Loading branch information
lgou2w committed Oct 10, 2023
1 parent b1520b9 commit 4a05bcf
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/gacha/GachaLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useEffect, useRef } from 'react'
import { useImmer } from 'use-immer'
import { useStatefulAccountContext } from '@/hooks/useStatefulAccount'
import { useGachaRecordsQuery } from '@/hooks/useGachaRecordsQuery'
Expand Down Expand Up @@ -28,6 +28,18 @@ export default function GachaLayout () {
} | undefined
})

// HACK: Clear alert if switching to another account
const selectedAccountUidRef = useRef(selectedAccountUid)
useEffect(() => {
if (selectedAccountUidRef.current !== selectedAccountUid) {
produceState((prev) => {
prev.alert = undefined
})
}

selectedAccountUidRef.current = selectedAccountUid
}, [selectedAccountUid])

// Check selected account
const selectedAccount = selectedAccountUid ? accounts[selectedAccountUid] : null
if (!selectedAccount) {
Expand Down

0 comments on commit 4a05bcf

Please sign in to comment.