/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import React, { useContext, useEffect, useState } from 'react'; import { useParams } from 'react-router-dom'; import NavbarContext from '../context/NavbarContext'; import client from '../util/client'; import useLocalStorage from '../util/useLocalStorage'; const style = { display: 'flex', flexDirection: 'column', justifyContent: 'center', margin: '0 auto', backgroundColor: '#343a40', } as React.CSSProperties; const range = (n:number) => Array.from({ length: n }, (value, key) => key); export default function Reader() { const { setTitle, setAction } = useContext(NavbarContext); useEffect(() => { setTitle('Reader'); setAction(<>); }, []); const [serverAddress] = useLocalStorage('serverBaseURL', ''); const [pageCount, setPageCount] = useState(-1); const { chapterId, mangaId } = useParams<{chapterId: string, mangaId: string}>(); useEffect(() => { client.get(`/api/v1/manga/${mangaId}/chapter/${chapterId}`) .then((response) => response.data) .then((data:IChapter) => { setTitle(data.name); setPageCount(data.pageCount); }); }, []); if (pageCount === -1) { return (

wait

); } const mapped = range(pageCount).map((index) => (
F
)); return (
{mapped}
); }