Don't load worker while loading event
This commit is contained in:
parent
e49a7e8c97
commit
ab6e03adac
|
|
@ -44,16 +44,18 @@ const EventAvailabilities = ({ event }: EventAvailabilitiesProps) => {
|
||||||
const [table, setTable] = useState<ReturnType<typeof calculateTable>>()
|
const [table, setTable] = useState<ReturnType<typeof calculateTable>>()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!tableWorker.current) {
|
if (event && expandTimes.length > 0) {
|
||||||
tableWorker.current = window.Worker ? new Worker(new URL('/src/workers/calculateTable', import.meta.url)) : undefined
|
if (!tableWorker.current) {
|
||||||
}
|
tableWorker.current = window.Worker ? new Worker(new URL('/src/workers/calculateTable', import.meta.url)) : undefined
|
||||||
const args = { times: expandedTimes, locale: i18n.language, timeFormat, timezone }
|
}
|
||||||
if (tableWorker.current) {
|
const args = { times: expandedTimes, locale: i18n.language, timeFormat, timezone }
|
||||||
tableWorker.current.onmessage = (e: MessageEvent<ReturnType<typeof calculateTable>>) => setTable(e.data)
|
if (tableWorker.current) {
|
||||||
tableWorker.current.postMessage(args)
|
tableWorker.current.onmessage = (e: MessageEvent<ReturnType<typeof calculateTable>>) => setTable(e.data)
|
||||||
setTable(undefined)
|
tableWorker.current.postMessage(args)
|
||||||
} else {
|
setTable(undefined)
|
||||||
setTable(calculateTable(args))
|
} else {
|
||||||
|
setTable(calculateTable(args))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [expandedTimes, i18n.language, timeFormat, timezone])
|
}, [expandedTimes, i18n.language, timeFormat, timezone])
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue