fix(reading-position): prevent tracking from toggling on/off

Added logic to properly disable tracking when isTextContent becomes false.
This prevents the tracking state from flipping and ensures saves work
consistently.

Now tracking is only enabled once content is stable and stays enabled
until the article changes or content becomes unsuitable.
This commit is contained in:
Gigi
2025-10-23 00:42:08 +02:00
parent d285003e1d
commit 039b988869

View File

@@ -221,9 +221,18 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
setIsTrackingEnabled(false)
}, [selectedUrl])
// Enable tracking after content is stable
// Enable/disable tracking based on content state
useEffect(() => {
if (isTextContent && !isTrackingEnabled) {
if (!isTextContent) {
// Disable tracking if content is not suitable
if (isTrackingEnabled) {
console.log('[reading-position] ⏸️ Disabling tracking (not text content)')
setIsTrackingEnabled(false)
}
return
}
if (!isTrackingEnabled) {
// Wait 500ms after content loads before enabling tracking
const timer = setTimeout(() => {
console.log('[reading-position] ✅ Enabling tracking after stability delay')