Full parallel implementation of typesense and opensearch

This commit is contained in:
Stefan Hardegger
2025-09-20 09:40:09 +02:00
parent 54df3c471e
commit f1773873d4
20 changed files with 2869 additions and 290 deletions

View File

@@ -40,7 +40,7 @@ export default function CollectionReadingView({
));
// Convert to character position in the plain text content
const textLength = story.contentPlain?.length || story.contentHtml.length;
const textLength = story.contentPlain?.length || story.contentHtml?.length || 0;
return Math.floor(scrollRatio * textLength);
}, [story]);
@@ -48,7 +48,7 @@ export default function CollectionReadingView({
const calculateReadingPercentage = useCallback((currentPosition: number): number => {
if (!story) return 0;
const totalLength = story.contentPlain?.length || story.contentHtml.length;
const totalLength = story.contentPlain?.length || story.contentHtml?.length || 0;
if (totalLength === 0) return 0;
return Math.round((currentPosition / totalLength) * 100);
@@ -58,7 +58,7 @@ export default function CollectionReadingView({
const scrollToCharacterPosition = useCallback((position: number) => {
if (!contentRef.current || !story || hasScrolledToPosition) return;
const textLength = story.contentPlain?.length || story.contentHtml.length;
const textLength = story.contentPlain?.length || story.contentHtml?.length || 0;
if (textLength === 0 || position === 0) return;
const ratio = position / textLength;