show story progress and reset last read when resetting progress.

This commit is contained in:
Stefan Hardegger
2025-10-30 13:44:54 +01:00
parent a3bc83db8a
commit 0e1ed7c92e
8 changed files with 62 additions and 19 deletions

View File

@@ -72,16 +72,8 @@ export default function StoryCard({
return new Date(dateString).toLocaleDateString();
};
const calculateReadingPercentage = (story: Story): number => {
if (!story.readingPosition) return 0;
const totalLength = story.contentPlain?.length || story.contentHtml?.length || 0;
if (totalLength === 0) return 0;
return Math.round((story.readingPosition / totalLength) * 100);
};
const readingPercentage = calculateReadingPercentage(story);
// Use the pre-calculated percentage from the backend
const readingPercentage = story.readingProgressPercentage || 0;
if (viewMode === 'list') {
return (

View File

@@ -16,6 +16,7 @@ export interface Story {
tags: Tag[];
tagNames?: string[] | null; // Used in search results
readingPosition?: number;
readingProgressPercentage?: number; // Pre-calculated percentage (0-100) from backend
lastReadAt?: string;
createdAt: string;
updatedAt: string;