fix: Prevent Duplicate Requests Between Tabs in Plugin Playground (#2113)
This commit is contained in:
Generated
+1383
-761
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -89,7 +89,7 @@
|
||||
"typescript-eslint": "^7.14.1",
|
||||
"urlencode": "^2.0.0",
|
||||
"vite": "^6.3.2",
|
||||
"vite-plugin-node-polyfills": "^0.23.0",
|
||||
"vite-plugin-node-polyfills": "^0.26.0",
|
||||
"zustand": "^5.0.1"
|
||||
},
|
||||
"lint-staged": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { Copy, FileText, Code } from 'lucide-react';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
@@ -29,6 +29,7 @@ export default function ParseChapterSection() {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [fetchError, setFetchError] = useState('');
|
||||
const [showRawHtml, setShowRawHtml] = useState(false);
|
||||
const lastProcessedPath = useRef<string>();
|
||||
|
||||
const { customCSSLoaded, customJSLoaded, customCSSError, customJSError } =
|
||||
usePluginCustomAssets(plugin, chapterText);
|
||||
@@ -70,6 +71,9 @@ export default function ParseChapterSection() {
|
||||
|
||||
// Handle pre-filled path from navigation
|
||||
useEffect(() => {
|
||||
if (parseChapterPath === lastProcessedPath.current) return;
|
||||
lastProcessedPath.current = parseChapterPath;
|
||||
|
||||
if (parseChapterPath) {
|
||||
setChapterPath(parseChapterPath);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import {
|
||||
BookOpen,
|
||||
ChevronLeft,
|
||||
@@ -45,6 +45,7 @@ export default function ParseNovelSection({
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [fetchError, setFetchError] = useState('');
|
||||
const lastProcessedPath = useRef<string>();
|
||||
|
||||
const { exportEpub, isExporting } = useEpubExport({
|
||||
plugin: plugin || null,
|
||||
@@ -118,6 +119,9 @@ export default function ParseNovelSection({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (parseNovelPath === lastProcessedPath.current) return;
|
||||
lastProcessedPath.current = parseNovelPath;
|
||||
|
||||
if (parseNovelPath) {
|
||||
setNovelPath(parseNovelPath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user