OhMyDitzzy commited on
Commit ·
0c51808
1
Parent(s): 70c6694
Anything
Browse files
src/modules/comic/ComicReader.tsx
CHANGED
|
@@ -36,19 +36,33 @@ export function ComicReader() {
|
|
| 36 |
const [showPageJump, setShowPageJump] = useState(false);
|
| 37 |
const [jumpPage, setJumpPage] = useState('');
|
| 38 |
const [loadingChapter, setLoadingChapter] = useState(false);
|
|
|
|
|
|
|
| 39 |
|
| 40 |
const imageRefs = useRef<{ [key: number]: HTMLImageElement | null }>({});
|
| 41 |
const controlsTimeout = useRef<number | null>(null);
|
| 42 |
const scrollContainerRef = useRef<HTMLDivElement | null>(null);
|
| 43 |
const wsRef = useRef<WebSocket | null>(null);
|
| 44 |
-
|
| 45 |
const chapterData = location.state?.chapterData;
|
| 46 |
-
const
|
| 47 |
-
const
|
| 48 |
|
| 49 |
-
// WebSocket setup
|
| 50 |
useEffect(() => {
|
| 51 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
| 54 |
const wsUrl = `${protocol}//${window.location.host}/ws`;
|
|
@@ -120,7 +134,7 @@ export function ComicReader() {
|
|
| 120 |
return;
|
| 121 |
}
|
| 122 |
|
| 123 |
-
if (!
|
| 124 |
setError('Unauthorized access - please open from comic page');
|
| 125 |
setLoading(false);
|
| 126 |
return;
|
|
@@ -128,7 +142,7 @@ export function ComicReader() {
|
|
| 128 |
|
| 129 |
setError('Please open chapter from comic page');
|
| 130 |
setLoading(false);
|
| 131 |
-
}, [sessionId,
|
| 132 |
|
| 133 |
useEffect(() => {
|
| 134 |
const resetTimeout = () => {
|
|
|
|
| 36 |
const [showPageJump, setShowPageJump] = useState(false);
|
| 37 |
const [jumpPage, setJumpPage] = useState('');
|
| 38 |
const [loadingChapter, setLoadingChapter] = useState(false);
|
| 39 |
+
const [password, setPassword] = useState<string>('');
|
| 40 |
+
const [originalSessionId, setOriginalSessionId] = useState<string>('');
|
| 41 |
|
| 42 |
const imageRefs = useRef<{ [key: number]: HTMLImageElement | null }>({});
|
| 43 |
const controlsTimeout = useRef<number | null>(null);
|
| 44 |
const scrollContainerRef = useRef<HTMLDivElement | null>(null);
|
| 45 |
const wsRef = useRef<WebSocket | null>(null);
|
|
|
|
| 46 |
const chapterData = location.state?.chapterData;
|
| 47 |
+
const statePassword = location.state?.password;
|
| 48 |
+
const stateSessionId = location.state?.sessionId;
|
| 49 |
|
|
|
|
| 50 |
useEffect(() => {
|
| 51 |
+
if (statePassword) {
|
| 52 |
+
console.log('[Reader] Setting password from state');
|
| 53 |
+
setPassword(statePassword);
|
| 54 |
+
}
|
| 55 |
+
if (stateSessionId) {
|
| 56 |
+
console.log('[Reader] Setting sessionId from state');
|
| 57 |
+
setOriginalSessionId(stateSessionId);
|
| 58 |
+
}
|
| 59 |
+
}, [statePassword, stateSessionId]);
|
| 60 |
+
|
| 61 |
+
useEffect(() => {
|
| 62 |
+
if (!password || !originalSessionId) {
|
| 63 |
+
console.log('[Reader] Waiting for password and sessionId...', { password: !!password, sessionId: !!originalSessionId });
|
| 64 |
+
return;
|
| 65 |
+
}
|
| 66 |
|
| 67 |
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
| 68 |
const wsUrl = `${protocol}//${window.location.host}/ws`;
|
|
|
|
| 134 |
return;
|
| 135 |
}
|
| 136 |
|
| 137 |
+
if (!statePassword || !stateSessionId) {
|
| 138 |
setError('Unauthorized access - please open from comic page');
|
| 139 |
setLoading(false);
|
| 140 |
return;
|
|
|
|
| 142 |
|
| 143 |
setError('Please open chapter from comic page');
|
| 144 |
setLoading(false);
|
| 145 |
+
}, [sessionId, statePassword, chapterData, stateSessionId]);
|
| 146 |
|
| 147 |
useEffect(() => {
|
| 148 |
const resetTimeout = () => {
|