diff --git a/api/stream.go b/api/stream.go index 9058a25cf..6f2ee9cb0 100644 --- a/api/stream.go +++ b/api/stream.go @@ -359,26 +359,44 @@ func (r streamRoutes) getStream(c *gin.Context) { func (r streamRoutes) getStreamPlaylist(c *gin.Context) { type StreamPlaylistEntry struct { - StreamID uint `json:"streamId"` - CourseSlug string `json:"courseSlug"` - StreamName string `json:"streamName"` - LiveNow bool `json:"liveNow"` - Watched bool `json:"watched"` - Start time.Time `json:"start"` - CreatedAt time.Time `json:"createdAt"` + StreamID uint `json:"streamId"` + CourseSlug string `json:"courseSlug"` + StreamName string `json:"streamName"` + LiveNow bool `json:"liveNow"` + Watched bool `json:"watched"` + Start time.Time `json:"start"` + StreamProgress model.StreamProgress `json:"streamProgress"` + CreatedAt time.Time `json:"createdAt"` } tumLiveContext := c.MustGet("TUMLiveContext").(tools.TUMLiveContext) + + // Create mapping of stream id to progress for all progresses of user + var streamIDs []uint + for _, stream := range tumLiveContext.Course.Streams { + streamIDs = append(streamIDs, stream.ID) + } + streamProgresses := make(map[uint]model.StreamProgress) + res, err := r.LoadProgress(tumLiveContext.User.ID, streamIDs) + if err != nil { + logger.Error("Couldn't load progresses", "err", err) + } else { + for _, progress := range res { + streamProgresses[progress.StreamID] = progress + } + } + var result []StreamPlaylistEntry for _, stream := range tumLiveContext.Course.Streams { result = append(result, StreamPlaylistEntry{ - StreamID: stream.ID, - CourseSlug: tumLiveContext.Course.Slug, - StreamName: stream.GetName(), - LiveNow: stream.LiveNow, - Watched: stream.Watched, - Start: stream.Start, - CreatedAt: stream.CreatedAt, + StreamID: stream.ID, + CourseSlug: tumLiveContext.Course.Slug, + StreamName: stream.GetName(), + LiveNow: stream.LiveNow, + Watched: stream.Watched, + Start: stream.Start, + StreamProgress: streamProgresses[stream.ID], + CreatedAt: stream.CreatedAt, }) } diff --git a/web/assets/css/watch.css b/web/assets/css/watch.css index 05b7ee1de..1e94242f0 100644 --- a/web/assets/css/watch.css +++ b/web/assets/css/watch.css @@ -1,5 +1,5 @@ .playlist-thumbnail { - @apply bg-gray-100 dark:bg-gray-800 rounded-lg mr-4 bg-cover transition-all duration-500 hover:shadow-xl dark:shadow-gray-900/75; + @apply relative bg-gray-100 dark:bg-gray-800 rounded-lg mr-4 bg-cover transition-all duration-500 hover:shadow-xl dark:shadow-gray-900/75; } /* Rendered, but not visible on the screen. Enables layout calculations. */ @@ -10,4 +10,4 @@ width: 100%; height: auto; overflow: visible; -} +} \ No newline at end of file diff --git a/web/template/partial/stream/playlist.gohtml b/web/template/partial/stream/playlist.gohtml index 065bd4d8e..001114dac 100644 --- a/web/template/partial/stream/playlist.gohtml +++ b/web/template/partial/stream/playlist.gohtml @@ -32,6 +32,15 @@