Set MessageChannel earlier

This commit is contained in:
Regalijan 2023-10-27 12:12:15 -04:00
parent 5c785a8255
commit 6017a62953
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -124,6 +124,10 @@ export default function () {
); );
const toast = useToast(); const toast = useToast();
useEffect(() => {
setMessageChannel(new MessageChannel());
}, []);
for (const type of pageProps.entry_types) for (const type of pageProps.entry_types)
entryTypes.push( entryTypes.push(
<option key={type.value} value={type.value}> <option key={type.value} value={type.value}>
@ -132,9 +136,7 @@ export default function () {
); );
useEffect(() => { useEffect(() => {
if (!messageChannel) { if (messageChannel) {
setMessageChannel(new MessageChannel());
} else {
messageChannel.port1.onmessage = function (ev) { messageChannel.port1.onmessage = function (ev) {
const { data }: { data: string } = ev; const { data }: { data: string } = ev;