diff --git a/src/components/accordions/ParseChapter/index.tsx b/src/components/accordions/ParseChapter/index.tsx
index 375439b..ca9e0b5 100644
--- a/src/components/accordions/ParseChapter/index.tsx
+++ b/src/components/accordions/ParseChapter/index.tsx
@@ -42,7 +42,7 @@ export default function ParseChapter() {
}}
maxRows={20}
disabled
- defaultValue={chapterText}
+ value={chapterText}
/>
) : null}
diff --git a/src/components/accordions/ParseNovel/SourceNovelCard.tsx b/src/components/accordions/ParseNovel/SourceNovelCard.tsx
index 3c1a99d..6e08cca 100644
--- a/src/components/accordions/ParseNovel/SourceNovelCard.tsx
+++ b/src/components/accordions/ParseNovel/SourceNovelCard.tsx
@@ -102,7 +102,7 @@ export default function SourceNovelCard({
diff --git a/src/components/accordions/PopularNovels/index.tsx b/src/components/accordions/PopularNovels/index.tsx
index 8fab9fc..9cf7779 100644
--- a/src/components/accordions/PopularNovels/index.tsx
+++ b/src/components/accordions/PopularNovels/index.tsx
@@ -1,5 +1,11 @@
-import { Box, Button, Stack } from '@mui/material';
-import React, { useEffect, useState } from 'react';
+import {
+ Box,
+ Button,
+ Stack,
+ ToggleButton,
+ ToggleButtonGroup,
+} from '@mui/material';
+import React, { useEffect, useState, ChangeEvent } from 'react';
import AccordionContainer from '../components/AccordionContainer';
import { Plugin } from '@typings/plugin';
import NovelItemCard from '../components/NovelItemCard';
@@ -11,16 +17,33 @@ export default function PopularNovels() {
const [novels, setNovels] = useState([]);
const [filterValues, setFilterValues] = useState();
const [loading, setLoading] = useState(false);
- const fetchNovels = () => {
- if (plugin) {
+ const [currentIndex, setCurrentIndex] = useState(0);
+ const [maxIndex, setMaxIndex] = useState(0);
+
+ const fetchNovelsByIndex = (index: number) => {
+ if (plugin && index) {
setLoading(true);
plugin
- .popularNovels(1, { filters: filterValues })
- .then(res => setNovels(res))
+ .popularNovels(index, { filters: filterValues })
+ .then(res => {
+ if (res.length !== 0) {
+ setCurrentIndex(index);
+ if (index > maxIndex) {
+ setMaxIndex(index);
+ }
+ setNovels(res);
+ }
+ })
.finally(() => setLoading(false));
}
};
+
useEffect(() => {
+ // Reset when changing plugins.
+ setCurrentIndex(0);
+ setMaxIndex(0);
+ setNovels([]);
+
if (plugin?.filters) {
let filters = {};
for (const fKey in plugin.filters) {
@@ -37,14 +60,31 @@ export default function PopularNovels() {
-