From 1e4613aa1113b373a8d841c28e222599237a33c5 Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Thu, 20 Jul 2023 20:52:13 +0200 Subject: feat: Add option to preload metadata Let the use pick if they want to preload videos' metadata. --- pkg/view/media.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'pkg/view/media.go') diff --git a/pkg/view/media.go b/pkg/view/media.go index e247940..6e34fd6 100644 --- a/pkg/view/media.go +++ b/pkg/view/media.go @@ -12,8 +12,9 @@ import ( type ( MediaView struct { - mediaRepository repository.MediaRepository - userRepository repository.UserRepository + mediaRepository repository.MediaRepository + userRepository repository.UserRepository + settingsRepository repository.SettingsRepository } ) @@ -50,10 +51,12 @@ func getPagination(ctx *fasthttp.RequestCtx) *repository.Pagination { func NewMediaView( mediaRepository repository.MediaRepository, userRepository repository.UserRepository, + settingsRepository repository.SettingsRepository, ) *MediaView { return &MediaView{ - mediaRepository: mediaRepository, - userRepository: userRepository, + mediaRepository: mediaRepository, + userRepository: userRepository, + settingsRepository: settingsRepository, } } @@ -72,12 +75,18 @@ func (self *MediaView) Index(ctx *fasthttp.RequestCtx) error { return err } + settings, err := self.settingsRepository.Load(ctx) + if err != nil { + return err + } + page := &templates.MediaPage{ Medias: medias, Next: &repository.Pagination{ Size: p.Size, Page: p.Page + 1, }, + Settings: settings, } templates.WritePageTemplate(ctx, page) -- cgit v1.2.3