import * as React from "react"; import { isUndefined } from "lodash"; import { connect } from "react-redux"; import { fetchComicBookMetadata } from "../actions/fileops.actions"; import { IFolderData } from "threetwo-ui-typings"; import { io, Socket } from "socket.io-client"; import { SOCKET_BASE_URI } from "../constants/endpoints"; import DynamicList, { createCache } from "react-window-dynamic-list"; interface IProps { matches: unknown; fetchComicMetadata: any; path: string; covers: any; } interface IState { folderWalkResults?: Array; searchPaneIndex: number; fileOps: any; } let socket: Socket; class Import extends React.Component { constructor(props: IProps) { super(props); this.state = { folderWalkResults: [], searchPaneIndex: undefined, }; } public toggleSearchResultsPane(paneId: number): void { this.setState({ searchPaneIndex: paneId, }); } /** * This initializes a socket.io connection instance with supplied configuration * * @return {void} A good string * * @example * * initiateSocketConnection() */ public initiateSocketConnection = () => { if (typeof this.props.path !== "undefined") { socket = io(SOCKET_BASE_URI, { reconnectionDelayMax: 10000, }); socket.on("connect", () => { console.log(`connect ${socket.id}`); }); this.props.fetchComicMetadata(); } }; public cache = createCache(); public renderRow = ({ index, style }) => (
{index}
cover {this.props.covers[index].comicBookCoverMetadata.name}
imported from
path {this.props.covers[index].comicBookCoverMetadata.path}
          
            
          
          {JSON.stringify(this.props.covers[index].dbImportResult, null, 2)}
        
); public render() { return (

Import

Import Only will add comics identified from the mapped folder into the local db.

Import and Tag will scan the ComicVine, shortboxed APIs and import comics from the mapped folder with the additional metadata.

{!isUndefined(this.state.folderWalkResults) ? (
{this.renderRow}
) : null}
); } } function mapStateToProps(state: IState) { console.log("state", state); return { // matches: state.comicInfo.searchResults, covers: state.fileOps.comicBookMetadata, }; } const mapDispatchToProps = (dispatch, ownProps) => ({ fetchComicMetadata() { dispatch(fetchComicBookMetadata(ownProps.path)); }, }); export default connect(mapStateToProps, mapDispatchToProps)(Import); export { socket };