mirror of
https://github.com/sbondCo/Watcharr.git
synced 2026-08-07 07:14:44 +00:00
wip: content: move watched entry to inside content object
instead of separating both, should be easier to work with this way and enable it to work for search results without complex mapping etc to find related watched entries
This commit is contained in:
+2
-2
@@ -234,7 +234,7 @@ func (b *BaseRouter) addContentRoutes() {
|
||||
return
|
||||
}
|
||||
userId := c.MustGet("userId").(uint)
|
||||
resp := DataWithWatched[TMDBShowDetails]{}
|
||||
resp := TMDBShowDetailsWithWatched{}
|
||||
// 1. Get details
|
||||
content, err := tvDetails(
|
||||
b.db,
|
||||
@@ -248,7 +248,7 @@ func (b *BaseRouter) addContentRoutes() {
|
||||
c.JSON(http.StatusBadRequest, ErrorResponse{Error: err.Error()})
|
||||
return
|
||||
}
|
||||
resp.Data = &content
|
||||
resp.TMDBShowDetails = &content
|
||||
// 2. append watched list entry if exists
|
||||
if watchedEntry, err := getWatchedItemByTmdbId(b.db, userId, uint(tmdbId), SHOW); err != nil {
|
||||
if err != gorm.ErrRecordNotFound {
|
||||
|
||||
+6
-5
@@ -75,9 +75,7 @@ type WatchedRemoveResponse struct {
|
||||
NewActivity Activity `json:"newActivity"`
|
||||
}
|
||||
|
||||
// Generic for returning data of (T)ype along with any
|
||||
// related watched entry data.
|
||||
type DataWithWatched[T any] struct {
|
||||
type WatchedAddedToContent struct {
|
||||
// The related watched entry.
|
||||
Watched *Watched `json:"watched,omitempty"`
|
||||
// If we failed to get the watched entry,
|
||||
@@ -85,8 +83,11 @@ type DataWithWatched[T any] struct {
|
||||
// notify the user of why there is possibly
|
||||
// missing watched list data.
|
||||
FailedToGetWatched bool `json:"failedToGetWatched,omitempty"`
|
||||
// The data going along with response.
|
||||
Data *T `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type TMDBShowDetailsWithWatched struct {
|
||||
WatchedAddedToContent
|
||||
*TMDBShowDetails
|
||||
}
|
||||
|
||||
// Get entire watched list
|
||||
|
||||
Reference in New Issue
Block a user