feat(api): enhance reading progress interfaces and add fetch endpoint
Update reading progress tracking on the frontend: - Add epubcfi and percentage fields to ReadingProgress interface - Add last_read_at timestamp for progress display - Implement getReadingProgress() function to fetch current progress - Export getReadingProgress for use in reader components These changes align the frontend API with the new backend progress schema and enable readers to retrieve saved position data.
This commit is contained in:
+16
-1
@@ -103,6 +103,9 @@ interface Chapter {
|
||||
interface ReadingProgress {
|
||||
current_page: number;
|
||||
total_pages: number;
|
||||
epubcfi?: string;
|
||||
percentage?: number;
|
||||
last_read_at: string;
|
||||
}
|
||||
async function getReaderMetadata(mediaItemId: string): Promise<ReaderMetadata> {
|
||||
const response = await apiGet(`/media-items/${mediaItemId}`);
|
||||
@@ -119,6 +122,18 @@ async function updateReadingProgress(
|
||||
await handleVoidResponse(response);
|
||||
}
|
||||
|
||||
async function getReadingProgress(
|
||||
mediaItemId: string,
|
||||
): Promise<ReadingProgress | null> {
|
||||
const response = await apiGet(`/media-items/${mediaItemId}/progress`);
|
||||
|
||||
if (response.status === 404) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return handleResponse<ReadingProgress>(response);
|
||||
}
|
||||
|
||||
export {
|
||||
apiGet,
|
||||
apiPost,
|
||||
@@ -129,8 +144,8 @@ export {
|
||||
handleVoidResponse,
|
||||
handleError,
|
||||
getReaderMetadata,
|
||||
getReadingProgress, // ADD THIS
|
||||
updateReadingProgress,
|
||||
ReaderMetadata,
|
||||
ReadingProgress,
|
||||
ChapterMetadata,
|
||||
Chapter,
|
||||
|
||||
Reference in New Issue
Block a user