🔧 Refactoring uncompression methods on client-side

This commit is contained in:
2022-12-01 13:11:02 -08:00
parent 0e73f9dad1
commit 592da9bd2a
4 changed files with 41 additions and 32 deletions

View File

@@ -256,35 +256,38 @@ export const fetchComicVineMatches =
/**
* This method is a proxy to `uncompressFullArchive` which uncompresses complete `rar` or `zip` archives
* @param {string} path The path to the compressed archive
* @param {any} options Options object
* @param {any} options Options object
* @returns {any}
*/
export const extractComicArchive = (path: string, options: any) => async (dispatch) => {
const comicBookPages: string[] = [];
dispatch({
type: IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_CALL_IN_PROGRESS,
});
const extractedComicBookArchive = await axios({
method: "POST",
url: `${LIBRARY_SERVICE_BASE_URI}/uncompressFullArchive`,
headers: {
"Content-Type": "application/json; charset=utf-8",
},
data: {
filePath: path,
},
});
map(extractedComicBookArchive.data, (page) => {
console.log(page);
const pageFilePath = removeLeadingPeriod(page);
const imagePath = encodeURI(`${LIBRARY_SERVICE_HOST}${pageFilePath}`);
comicBookPages.push(imagePath);
});
dispatch({
type: IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_SUCCESS,
extractedComicBookArchive: comicBookPages,
});
};
export const extractComicArchive =
(path: string, options: any): any => async (dispatch) => {
const comicBookPages: string[] = [];
console.log(options);
dispatch({
type: IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_CALL_IN_PROGRESS,
});
const extractedComicBookArchive = await axios({
method: "POST",
url: `${LIBRARY_SERVICE_BASE_URI}/uncompressFullArchive`,
headers: {
"Content-Type": "application/json; charset=utf-8",
},
data: {
filePath: path,
...options,
},
});
map(extractedComicBookArchive.data, (page) => {
console.log(page);
const pageFilePath = removeLeadingPeriod(page);
const imagePath = encodeURI(`${LIBRARY_SERVICE_HOST}${pageFilePath}`);
comicBookPages.push(imagePath);
});
dispatch({
type: IMS_COMIC_BOOK_ARCHIVE_EXTRACTION_SUCCESS,
extractedComicBookArchive: comicBookPages,
});
};
export const searchIssue = (query, options) => async (dispatch) => {
dispatch({

View File

@@ -74,7 +74,13 @@ export const ComicDetail = (data: ComicDetailProps): ReactElement => {
const openModal = useCallback((filePath) => {
setIsOpen(true);
dispatch(extractComicArchive(filePath));
dispatch(extractComicArchive(filePath, {
type: "full",
purpose: "readComicBook",
imageResizeOptions: {
baseWidth: 275,
}
}));
}, []);
const afterOpenModal = useCallback((things) => {
@@ -249,7 +255,7 @@ export const ComicDetail = (data: ComicDetailProps): ReactElement => {
</div>
</div>
{/* raw file details */}
<div className="column is-three-fifths">
<div className="column">
{!isUndefined(rawFileDetails) &&
!isEmpty(rawFileDetails.cover) && (
<>

View File

@@ -7,7 +7,7 @@ import Card from "../Carda";
export const ComicVineDetails = (props): ReactElement => {
const { data, updatedAt } = props;
return (
<div className="column is-two-thirds">
<div className="column is-half">
<div className="comic-detail comicvine-metadata">
<dl>
<dt>ComicVine Metadata</dt>

View File

@@ -7,7 +7,7 @@ export const RawFileDetails = (props): ReactElement => {
const { rawFileDetails, inferredMetadata } = props.data;
return (
<>
<div className="comic-detail raw-file-details">
<div className="comic-detail raw-file-details column is-three-fifths">
<dl>
<dt>Raw File Details</dt>
<dd className="is-size-7">
@@ -38,7 +38,7 @@ export const RawFileDetails = (props): ReactElement => {
</dd>
</dl>
</div>
<div className="content comic-detail raw-file-details mt-3">
<div className="content comic-detail raw-file-details mt-3 column is-one-third">
<dl>
{/* inferred metadata */}
<dt>Inferred Issue Metadata</dt>