Skip to content

Commit

Permalink
fix(token lists): stop showing notifications for lists that are not s…
Browse files Browse the repository at this point in the history
…elected (#1174)
  • Loading branch information
moodysalem authored Oct 20, 2020
1 parent 32ac255 commit ddf8834
Showing 1 changed file with 32 additions and 25 deletions.
57 changes: 32 additions & 25 deletions src/state/lists/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -54,45 +57,49 @@ 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,
content: {
listUpdate: {
listUrl,
oldList: list.current,
newList: list.pendingUpdate,
auto: true
}
}
})
)
}
} 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`
)
}
break

case VersionUpgrade.MAJOR:
if (listUrl === selectedListUrl) {
dispatch(
addPopup({
key: listUrl,
content: {
listUpdate: {
listUrl,
auto: false,
oldList: list.current,
newList: list.pendingUpdate,
auto: true
newList: list.pendingUpdate
}
}
},
removeAfterMs: 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`
)
}
break

case VersionUpgrade.MAJOR:
dispatch(
addPopup({
key: listUrl,
content: {
listUpdate: {
listUrl,
auto: false,
oldList: list.current,
newList: list.pendingUpdate
}
},
removeAfterMs: null
})
)
}
}
})
}, [dispatch, lists])
}, [dispatch, lists, selectedListUrl])

return null
}

1 comment on commit ddf8834

@vercel
Copy link

@vercel vercel bot commented on ddf8834 Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.