feat(api): migrate reading progress to universal progress tracking
Refactor UpdateMediaReadingProgress handler to use UpdateUniversalProgress database function, providing comprehensive progress tracking capabilities including device sync information, viewport data, reading mode, and scroll position for enhanced cross-platform reading synchronization.
This commit is contained in:
1 parent
53cc674435
commit
c62280beaa
1 file changed
+19
-7
@@ -933,13 +933,25 @@ func (mh *MediaHandler) UpdateMediaReadingProgress(c *echo.Context) error {
|
|||||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": err.Error()})
|
return c.JSON(http.StatusBadRequest, map[string]string{"error": err.Error()})
|
||||||
}
|
}
|
||||||
|
|
||||||
progress, err := mh.db.UpdateReadingProgress(c.Request().Context(), database.UpdateReadingProgressParams{
|
progress, err := mh.db.UpdateUniversalProgress(c.Request().Context(), database.UpdateUniversalProgressParams{
|
||||||
MediaItemID: pgtype.UUID{Bytes: mediaUUID, Valid: true},
|
MediaItemID: pgtype.UUID{Bytes: mediaUUID, Valid: true},
|
||||||
UserID: pgtype.UUID{Bytes: userUUID, Valid: true},
|
UserID: pgtype.UUID{Bytes: userUUID, Valid: true},
|
||||||
CurrentPage: pgtype.Int4{Int32: req.CurrentPage, Valid: true},
|
Percentage: pgtype.Float8{Float64: req.Percentage, Valid: true},
|
||||||
TotalPages: pgtype.Int4{Int32: req.TotalPages, Valid: req.TotalPages > 0},
|
CharacterOffset: pgtype.Int8{Valid: false},
|
||||||
Epubcfi: req.Epubcfi,
|
Epubcfi: pgtype.Text{String: req.Epubcfi, Valid: req.Epubcfi != ""},
|
||||||
Percentage: req.Percentage,
|
Chapter: pgtype.Int4{Valid: false},
|
||||||
|
ChapterProgress: pgtype.Float8{Valid: false},
|
||||||
|
ViewportX: pgtype.Float8{Valid: false},
|
||||||
|
ViewportY: pgtype.Float8{Valid: false},
|
||||||
|
ZoomLevel: pgtype.Float8{Valid: false},
|
||||||
|
ScrollPositionX: pgtype.Float8{Valid: false},
|
||||||
|
ScrollPositionY: pgtype.Float8{Valid: false},
|
||||||
|
PanelNumber: pgtype.Int4{Valid: false},
|
||||||
|
ReadingMode: pgtype.Text{Valid: false},
|
||||||
|
LastSyncDevice: pgtype.Text{String: "web", Valid: true},
|
||||||
|
LastSyncSource: pgtype.Text{String: "web", Valid: true},
|
||||||
|
CurrentPage: pgtype.Int4{Int32: req.CurrentPage, Valid: true},
|
||||||
|
TotalPages: pgtype.Int4{Int32: req.TotalPages, Valid: req.TotalPages > 0},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
||||||
|
|||||||
Reference in new issue
Block a user