feat: get web worker mechanism working (pass file around)

This commit is contained in:
鲁树人
2023-05-08 17:36:10 +01:00
parent 29b169cce6
commit 911ee2a2fa
7 changed files with 150 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ import React, { useId } from 'react';
import { Box, Text } from '@chakra-ui/react';
import { UnlockIcon } from '@chakra-ui/icons';
import { useAppDispatch } from './hooks';
import { addNewFile } from './features/file-listing/fileListingSlice';
import { addNewFile, processFile } from './features/file-listing/fileListingSlice';
import { nanoid } from 'nanoid';
export function SelectFile() {
@@ -15,13 +15,16 @@ export function SelectFile() {
for (const file of e.target.files) {
const blobURI = URL.createObjectURL(file);
const fileName = file.name;
const fileId = 'file://' + nanoid();
// FIXME: this should be a single action/thunk that first adds the item, then updates it.
dispatch(
addNewFile({
id: nanoid(),
id: fileId,
blobURI,
fileName,
})
);
dispatch(processFile(fileId));
}
}