Compare commits

...

2 Commits

Author SHA1 Message Date
32a6f9d7a3 Merge pull request #199 from hotfix-remove-loop-9-12 into staging
All checks were successful
Release to Staging / build_and_release (push) Successful in 1m16s
Reviewed-on: #199
Reviewed-by: eugene <eugene@nostrdev.com>
2024-09-12 09:32:54 +00:00
5f0234a358 fix: remove unstable fetch events loop
All checks were successful
Open PR on Staging / audit_and_check (pull_request) Successful in 34s
2024-09-12 11:27:55 +02:00

View File

@ -27,8 +27,6 @@ import {
import { useAppSelector } from '../hooks'
import styles from './style.module.scss'
const UPDATE_INTERVAL_MS = 120000
export const MainLayout = () => {
const dispatch: Dispatch = useDispatch()
const [isLoading, setIsLoading] = useState(true)
@ -37,7 +35,7 @@ export const MainLayout = () => {
const usersAppData = useAppSelector((state) => state.userAppData)
// Ref to track if `subscribeForSigits` has been called
const hasSubscribed = useRef<number | null>(null)
const hasSubscribed = useRef(false)
useEffect(() => {
const metadataController = new MetadataController()
@ -111,27 +109,11 @@ export const MainLayout = () => {
if (pubkey && !hasSubscribed.current) {
// Call `subscribeForSigits` only if it hasn't been called before
// #193 disabled websocket subscribtion, keep updating the sigits on UPDATE_INTERVAL_MS until #194 is done
// Set up the update sigit loop, use setTimeout to make sure times between updates are consistent
// (not affected by execution duration of subscribeForSigits call)
const loop = () => {
hasSubscribed.current = window.setTimeout(async () => {
await subscribeForSigits(pubkey)
loop()
}, UPDATE_INTERVAL_MS)
}
// #193 disabled websocket subscribtion, until #194 is done
subscribeForSigits(pubkey)
loop()
// Mark `subscribeForSigits` as called
//hasSubscribed.current = true
}
}
return () => {
if (hasSubscribed.current) {
window.clearTimeout(hasSubscribed.current)
hasSubscribed.current = null
hasSubscribed.current = true
}
}
}, [authState, usersAppData])