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>>()
|
||||
|
||||
useEffect(() => {
|
||||
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) {
|
||||
tableWorker.current.onmessage = (e: MessageEvent<ReturnType<typeof calculateTable>>) => setTable(e.data)
|
||||
tableWorker.current.postMessage(args)
|
||||
setTable(undefined)
|
||||
} else {
|
||||
setTable(calculateTable(args))
|
||||
if (event && expandTimes.length > 0) {
|
||||
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) {
|
||||
tableWorker.current.onmessage = (e: MessageEvent<ReturnType<typeof calculateTable>>) => setTable(e.data)
|
||||
tableWorker.current.postMessage(args)
|
||||
setTable(undefined)
|
||||
} else {
|
||||
setTable(calculateTable(args))
|
||||
}
|
||||
}
|
||||
}, [expandedTimes, i18n.language, timeFormat, timezone])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue