From f493b6507a42feabbb386c58db7e2cd64e5af305 Mon Sep 17 00:00:00 2001 From: Aaron Leopold <36278431+aaronleopold@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:26:10 -0700 Subject: [PATCH 1/2] :bug: Fix hotkey bug in image reader Fixes #203 --- .../readers/image-based/PagedReader.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/interface/src/components/readers/image-based/PagedReader.tsx b/packages/interface/src/components/readers/image-based/PagedReader.tsx index 403d58092..c8dd1b6b7 100644 --- a/packages/interface/src/components/readers/image-based/PagedReader.tsx +++ b/packages/interface/src/components/readers/image-based/PagedReader.tsx @@ -20,11 +20,11 @@ export type PagedReaderProps = { } /** - * A component that renders a reader for image-based media. Images are displayed one at a time, + * A reader component for image-based media. Images are displayed one at a time, * however preloading is done to reduce wait times for consecutive pages. * * Note: This component lacks animations between pages. The `AnimatedPagedReader` component - * has animations, as the name suggests lol. + * will have animations between pages, but is currently a WIP */ export default function PagedReader({ currentPage, @@ -36,13 +36,14 @@ export default function PagedReader({ const [toolbarVisible, { toggle: toggleToolbar, off: hideToolbar }] = useBoolean(false) + const pageCount = media.pages /** * This effect is responsible for preloading the next 2 pages relative to the current page. This is done to * try and prevent wait times for the next page to load. */ useEffect( () => { - const pageArray = Array.from({ length: media.pages }) + const pageArray = Array.from({ length: pageCount }) const start = currentPage >= 1 ? currentPage - 1 : 0 @@ -53,7 +54,7 @@ export default function PagedReader({ }, // eslint-disable-next-line react-hooks/exhaustive-deps - [currentPage, media.pages], + [currentPage, pageCount], ) /** @@ -82,10 +83,10 @@ export default function PagedReader({ * A simple function that does a little bit of validation before calling the onPageChange callback. * This is done to prevent the user from going to a page that doesn't exist. * - * @param newPage The new page to navigate to + * @param newPage The new page to navigate to (1-indexed) */ function handlePageChange(newPage: number) { - if (newPage < media.pages && newPage > 0) { + if (newPage <= media.pages && newPage > 0) { onPageChange(newPage) } } @@ -126,7 +127,8 @@ export default function PagedReader({ visible={toolbarVisible} onPageChange={handlePageChange} /> - onPageChange(currentPage - 1)} /> + handlePageChange(currentPage - 1)} /> + {/* TODO: better error handling for the loaded image */} - onPageChange(currentPage + 1)} /> + handlePageChange(currentPage + 1)} /> ) } From 0be16bb916b9ca84f4f82390f36a63d5c6e57f46 Mon Sep 17 00:00:00 2001 From: Aaron Leopold <36278431+aaronleopold@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:31:18 -0700 Subject: [PATCH 2/2] :technologist: Add nuke script to clean cargo and pnpm --- apps/desktop/moon.yml | 13 +++---------- apps/web/moon.yml | 3 +++ docs/moon.yml | 3 +++ package.json | 4 +++- packages/components/moon.yml | 3 +++ pnpm-lock.yaml | 11 +++++++++++ 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/apps/desktop/moon.yml b/apps/desktop/moon.yml index bc3ae6728..3d0dc1755 100644 --- a/apps/desktop/moon.yml +++ b/apps/desktop/moon.yml @@ -34,13 +34,6 @@ tasks: mergeDeps: 'replace' mergeInputs: 'replace' - # # TODO: need to have more targets. - # build: - # # tauri build --target universal-apple-darwin - # command: 'pnpm tauri build' - # local: true - # deps: - # - '~:build-webapp' - - # build-webapp: - # command: 'pnpm vite build' + nuke: + command: 'pnpm exec rimraf -rf node_modules' + local: true diff --git a/apps/web/moon.yml b/apps/web/moon.yml index aa46eea7a..53db43db9 100644 --- a/apps/web/moon.yml +++ b/apps/web/moon.yml @@ -22,3 +22,6 @@ tasks: build: command: 'vite build' local: true + + nuke: + command: 'rimraf -rf node_modules' diff --git a/docs/moon.yml b/docs/moon.yml index 4c680800e..6fa59ebb7 100644 --- a/docs/moon.yml +++ b/docs/moon.yml @@ -37,3 +37,6 @@ tasks: options: shell: true runFromWorkspaceRoot: false + + nuke: + command: 'rimraf -rf node_modules' diff --git a/package.json b/package.json index 981b42176..d58ad901d 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "build:web": "pnpm web build && pnpm build:server", "build:desktop": "pnpm desktop build", "moon": "moon --color --log trace", - "prettify": "prettier --config prettier.config.js --ignore-path .prettierignore --write ." + "prettify": "prettier --config prettier.config.js --ignore-path .prettierignore --write .", + "nuke": "cargo clean && cargo codegen && moon run :nuke && pnpm i" }, "devDependencies": { "@babel/core": "^7.23.2", @@ -46,6 +47,7 @@ "prettier": "^3.0.3", "prettier-eslint": "^16.1.1", "prettier-plugin-tailwindcss": "^0.5.6", + "rimraf": "^5.0.5", "trash-cli": "^5.0.0", "tsconfig-moon": "^1.3.0", "typescript": "^5.2.2" diff --git a/packages/components/moon.yml b/packages/components/moon.yml index fdf2c3920..49a06e493 100644 --- a/packages/components/moon.yml +++ b/packages/components/moon.yml @@ -8,3 +8,6 @@ tasks: storybook: command: 'start-storybook -p 6006' local: true + + nuke: + command: 'rimraf -rf node_modules' diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1218c2c00..f5c38ff14 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -68,6 +68,9 @@ importers: prettier-plugin-tailwindcss: specifier: ^0.5.6 version: 0.5.6(prettier@3.0.3) + rimraf: + specifier: ^5.0.5 + version: 5.0.5 trash-cli: specifier: ^5.0.0 version: 5.0.0 @@ -15143,6 +15146,14 @@ packages: glob: 7.2.3 dev: true + /rimraf@5.0.5: + resolution: {integrity: sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==} + engines: {node: '>=14'} + hasBin: true + dependencies: + glob: 10.3.10 + dev: true + /robust-predicates@3.0.2: resolution: {integrity: sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==} dev: false