Skip to content

Commit 9796c04

Browse files
slow down polling interval (Uniswap#420)
1 parent 54ef651 commit 9796c04

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/contexts/Application.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,23 @@ export default function Provider({ children }) {
6868
}
6969

7070
export function Updater() {
71-
const { networkId, library } = useWeb3Context()
71+
const { networkId, library, connectorName } = useWeb3Context()
7272

7373
const globalBlockNumber = useBlockNumber()
7474
const [, { updateBlockNumber, updateUSDPrice }] = useApplicationContext()
7575

76+
// slow down polling interval
77+
useEffect(() => {
78+
if (library) {
79+
if (connectorName === 'Network') {
80+
library.pollingInterval = 15
81+
} else {
82+
library.pollingInterval = 5
83+
}
84+
}
85+
}, [library, connectorName])
86+
87+
// update usd price
7688
useEffect(() => {
7789
let stale = false
7890

@@ -89,6 +101,7 @@ export function Updater() {
89101
})
90102
}, [globalBlockNumber, library, networkId, updateUSDPrice])
91103

104+
// update block number
92105
useEffect(() => {
93106
if ((networkId || networkId === 0) && library) {
94107
let stale = false

0 commit comments

Comments
 (0)