Commit ddf88345 authored by Moody Salem's avatar Moody Salem Committed by GitHub

fix(token lists): stop showing notifications for lists that are not selected (#1174)

parent 32ac2555
......@@ -13,6 +13,9 @@ export default function Updater(): null {
const { library } = useActiveWeb3React()
const dispatch = useDispatch<AppDispatch>()
const lists = useSelector<AppState, AppState['lists']['byUrl']>(state => state.lists.byUrl)
const selectedListUrl = useSelector<AppState, AppState['lists']['selectedListUrl']>(
state => state.lists.selectedListUrl
)
const isWindowVisible = useIsWindowVisible()
......@@ -54,6 +57,7 @@ export default function Updater(): null {
// automatically update minor/patch as long as bump matches the min update
if (bump >= min) {
dispatch(acceptListUpdate(listUrl))
if (listUrl === selectedListUrl) {
dispatch(
addPopup({
key: listUrl,
......@@ -67,6 +71,7 @@ export default function Updater(): null {
}
})
)
}
} else {
console.error(
`List at url ${listUrl} could not automatically update because the version bump was only PATCH/MINOR while the update had breaking changes and should have been MAJOR`
......@@ -75,6 +80,7 @@ export default function Updater(): null {
break
case VersionUpgrade.MAJOR:
if (listUrl === selectedListUrl) {
dispatch(
addPopup({
key: listUrl,
......@@ -91,8 +97,9 @@ export default function Updater(): null {
)
}
}
}
})
}, [dispatch, lists])
}, [dispatch, lists, selectedListUrl])
return null
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment