diff --git a/src/client/components/Import.tsx b/src/client/components/Import.tsx
index 3643187..7bc0717 100644
--- a/src/client/components/Import.tsx
+++ b/src/client/components/Import.tsx
@@ -5,13 +5,7 @@ import axios from "axios";
import { withRouter } from "react-router-dom";
import { connect } from "react-redux";
import { comicinfoAPICall } from "../actions/comicinfo.actions";
-import MatchResult from "./MatchResult";
-import {
- IFolderData,
- IComicVineSearchMatch,
-} from "../shared/interfaces/comicinfo.interfaces";
-import { folderWalk } from "../shared/utils/folder.utils";
-// import {} from "../constants/comicvine.mock";
+import { IFolderData } from "../shared/interfaces/comicinfo.interfaces";
import * as Comlink from "comlink";
import WorkerAdd from "../workers/extractCovers.worker";
interface IProps {
@@ -26,7 +20,7 @@ class Import extends React.Component {
constructor(props: IProps) {
super(props);
this.state = {
- folderWalkResults: undefined,
+ folderWalkResults: [],
searchPaneIndex: undefined,
};
}
@@ -37,16 +31,9 @@ class Import extends React.Component {
});
}
- public async init() {
- // WebWorkers use `postMessage` and therefore work with Comlink.
- const { add } = Comlink.wrap(new WorkerAdd());
- const res = await add(1, 3);
- console.log(res);
- }
-
public async startFolderWalk(): Promise {
- this.init();
- const folderWalkResults = await folderWalk();
+ const { importComicBooks } = Comlink.wrap(new WorkerAdd());
+ const folderWalkResults = await importComicBooks;
this.setState({
folderWalkResults,
});
@@ -96,61 +83,9 @@ class Import extends React.Component {
{/* Folder walk results */}
{!_.isUndefined(this.state.folderWalkResults) ? (
-
-
-
- | Name |
- Format |
- Is File |
-
- {!_.isUndefined(this.state.folderWalkResults) &&
- this.state.folderWalkResults.map((result, idx) => (
-
- |
- {!result.isLink && !result.isFile ? (
-
-
-
-
- {result.name}
-
- ) : (
- {result.name}
- )}
-
- {this.state.searchPaneIndex === idx &&
- !_.isUndefined(this.props.matches) ? (
-
- ) : null}
- |
-
- {!_.isEmpty(result.extension) ? (
-
- {result.extension}
-
- ) : null}
- |
- {result.isFile.toString()} |
-
-
- |
-
- ))}
-
-
+ <>
+ poopie
+ >
) : null}
@@ -158,29 +93,14 @@ class Import extends React.Component {
}
}
-function mapStateToProps(state) {
+function mapStateToProps(state: IState) {
return {
- matches: state.comicInfo.searchResults,
+ // matches: state.comicInfo.searchResults,
};
}
const mapDispatchToProps = (dispatch) => ({
- findMatches(e, results) {
- dispatch(
- comicinfoAPICall({
- callURIAction: "search",
- callMethod: "get",
- callParams: {
- format: "json",
- query: results.name,
- limit: 10,
- offset: 5,
- sort: "name:asc",
- resources: "issue",
- },
- }),
- );
- },
+ name: "rishi",
});
export default connect(mapStateToProps, mapDispatchToProps)(Import);
diff --git a/src/client/components/MatchResult.tsx b/src/client/components/MatchResult.tsx
index a7d1431..e6ed81a 100644
--- a/src/client/components/MatchResult.tsx
+++ b/src/client/components/MatchResult.tsx
@@ -25,6 +25,65 @@ class MatchResult extends React.Component {
}
public render() {
+ {
+ /*
+
+
+
+ | Name |
+ Format |
+ Is File |
+
+ {!_.isUndefined(this.state.folderWalkResults) &&
+ this.state.folderWalkResults.map((result, idx) => (
+
+ |
+ {!result.isLink && !result.isFile ? (
+
+
+
+
+ {result.name}
+
+ ) : (
+ {result.name}
+ )}
+
+ {this.state.searchPaneIndex === idx &&
+ !_.isUndefined(this.props.matches) ? (
+
+ ) : null}
+ |
+
+ {!_.isEmpty(result.extension) ? (
+
+ {result.extension}
+
+ ) : null}
+ |
+ {result.isFile.toString()} |
+
+
+ |
+
+ ))}
+
+
+ */
+ }
return this.props.visible ? (
Matches
diff --git a/src/client/workers/extractCovers.worker.ts b/src/client/workers/extractCovers.worker.ts
index ac44056..53838f7 100644
--- a/src/client/workers/extractCovers.worker.ts
+++ b/src/client/workers/extractCovers.worker.ts
@@ -1,8 +1,9 @@
import * as Comlink from "comlink";
import { walkFolder } from "../actions/fileops.actions";
import { IExtractionOptions } from "../../server/interfaces/folder.interface";
+import { IFolderData } from "../shared/interfaces/comicinfo.interfaces";
-async function importComicBooks() {
+async function importComicBooks(): Promise {
// 1. Walk the folder structure
// 2. Scan for .cbz, .cbr
// 3. extract cover image
@@ -12,6 +13,7 @@ async function importComicBooks() {
// 6. Save model to mongo
const fileObjects = await walkFolder("./comics");
+ return fileObjects;
}
Comlink.expose({
diff --git a/src/server/route/routes/importComics.routes.ts b/src/server/route/routes/importComics.routes.ts
index 081148d..8201da7 100644
--- a/src/server/route/routes/importComics.routes.ts
+++ b/src/server/route/routes/importComics.routes.ts
@@ -7,17 +7,14 @@ import {
extractMetadataFromImage,
explodePath,
} from "../../utils/fs.utils";
+import { IExtractionOptions } from "../../interfaces/folder.interface";
import { Request, Response } from "express";
router.route("/getComicCovers").post(async (req: Request, res: Response) => {
- const options = {
- name: "30 Days of Night # 30 äíåé íî÷è # 01-001",
- extension: ".cbz",
- containedIn: "comics",
- isFile: true,
- isLink: false,
- };
- const foo = await extractArchive(options);
+ typeof req.body.extractionOptions === "object"
+ ? req.body.extractionOptions
+ : {};
+ const foo = await extractArchive(req.body.extractionOptions);
// const foo = await extractMetadataFromImage(
// "./comics/covers/Ghosts and Ruins-001.jpg",
// );