diff --git a/.github/workflows/azure-static-web-apps-calm-rock-07ad32503.yml b/.github/workflows/azure-static-web-apps-calm-rock-07ad32503.yml deleted file mode 100644 index ecf50a5..0000000 --- a/.github/workflows/azure-static-web-apps-calm-rock-07ad32503.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Azure Static Web Apps CI/CD - -on: - push: - branches: - - master - pull_request: - types: [opened, synchronize, reopened, closed] - branches: - - master - -jobs: - build_and_deploy_job: - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') - runs-on: ubuntu-latest - name: Checkout - steps: - - uses: actions/checkout@v4 - with: - submodules: true - lfs: false - - name: Build And Deploy - id: builddeploy - uses: Azure/static-web-apps-deploy@v1 - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_CALM_ROCK_07AD32503 }} - repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) - action: "upload" - ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### - app_location: "/" # App source code path - app_build_command: 'npm run build' - ###### End of Repository/Build Configurations ###### - - close_pull_request_job: - if: github.event_name == 'pull_request' && github.event.action == 'closed' - runs-on: ubuntu-latest - name: Close Pull Request Job - steps: - - name: Close Pull Request - id: closepullrequest - uses: Azure/static-web-apps-deploy@v1 - with: - app_location: "/" # Set this to the location of your application code - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_CALM_ROCK_07AD32503 }} - action: "close" diff --git a/src/components/read-mode-page.jsx b/src/components/read-mode-page.jsx index 47e0ce7..05ba158 100644 --- a/src/components/read-mode-page.jsx +++ b/src/components/read-mode-page.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from "react"; +import React, { useEffect, useState, useCallback } from "react"; import useDocumentTitle from "../functions/useDocumentTile.js"; import brailleTranslator from "../functions/translator/brailleTranslator.js"; import { filterUnnecessarySentence } from "../functions/filterSetences.js" @@ -16,63 +16,9 @@ export default function ReadModePageByPage({ savedPageIndex, setSavedPageIndex, useDocumentTitle(pefObject.metaData.titel); - useEffect(() => { - // Resave the pages array when it changes - renderPagesFromPefObject(); - }, [pefObject, bookView]); - - useEffect(() => { - if (currentPageIndex === null && savedPageIndex) { - setCurrentPageIndex(savedPageIndex) - } else if (autoSave && currentPageIndex) { - setSavedPageIndex(currentPageIndex) - } - }, [autoSave, currentPageIndex, savedPageIndex]); - - function handleNextPageBtn() { - if (currentPageIndex < maxPageIndex) { - setCurrentPageIndex(currentPageIndex + 1); - } else { - alert("Fel: Det finns inga fler sidor i boken."); - } - } - - function handlePreviousPageBtn() { - if (currentPageIndex > firstPageIndex) { - setCurrentPageIndex(currentPageIndex - 1); - } else { - alert("Fel: Du kan inte gå längre bakåt i den här boken."); - } - } - - function handleSetCurrentPage(index) { - if (currentPageIndex === index) { - if (index === firstPageIndex) { - alert('Du är redan på den första sidan.') - } else { - alert(`Du är redan på sidan ${index}.`) - } - } else { - setCurrentPageIndex(index) - return true - } - } - - // Render the current page in html - function showCurrentPage(pageIndex) { - if (pageIndex < firstPageIndex) { - return pages[firstPageIndex] - } else { - return pages[pageIndex] - } - } - - function renderPagesFromPefObject() { - // Array to store pages + const renderPagesFromPefObject = useCallback(() => { const pagesFromPefObject = []; - // Variable to store index of the first page let firstPageIndex; - // Variable to track current page index let pageIndex = 1; const volumes = pefObject.bodyData.volumes; @@ -85,22 +31,16 @@ export default function ReadModePageByPage({ savedPageIndex, setSavedPageIndex, if (section.pages) { const sectionPages = section.pages; for (let k = 0; k < sectionPages.length; k++) { - - // Apply manipulation to page index if necessary k = manipulatePageIndexToRemoveUnnecessaryPages(sectionPages, k); - const page = sectionPages[k] - const thisPageIndex = pageIndex + const page = sectionPages[k]; + const thisPageIndex = pageIndex; pageIndex++; - // Generate JSX element for page content const pageElement = page && page.rows && (