aboutsummaryrefslogtreecommitdiff
path: root/pkg/view
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-07-20 20:52:13 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-07-20 20:52:13 +0200
commit1e4613aa1113b373a8d841c28e222599237a33c5 (patch)
treed307a10051d6e504366e76a71c17cba7deda47ac /pkg/view
parent64603aa1e13ba82b9393b9eb91b6332237f45821 (diff)
downloadlens-1e4613aa1113b373a8d841c28e222599237a33c5.tar.gz
lens-1e4613aa1113b373a8d841c28e222599237a33c5.tar.bz2
lens-1e4613aa1113b373a8d841c28e222599237a33c5.zip
feat: Add option to preload metadata
Let the use pick if they want to preload videos' metadata.
Diffstat (limited to 'pkg/view')
-rw-r--r--pkg/view/media.go17
-rw-r--r--pkg/view/settings.go10
2 files changed, 19 insertions, 8 deletions
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)
diff --git a/pkg/view/settings.go b/pkg/view/settings.go
index bee3dc2..ffce86b 100644
--- a/pkg/view/settings.go
+++ b/pkg/view/settings.go
@@ -47,13 +47,15 @@ func (self *SettingsView) Index(ctx *fasthttp.RequestCtx) error {
func (self *SettingsView) Save(ctx *fasthttp.RequestCtx) error {
var (
- showMode = string(ctx.FormValue("showMode")) == "on"
- showOwner = string(ctx.FormValue("showOwner")) == "on"
+ showMode = string(ctx.FormValue("showMode")) == "on"
+ showOwner = string(ctx.FormValue("showOwner")) == "on"
+ preloadVideoMetadata = string(ctx.FormValue("preloadVideoMetadata")) == "on"
)
err := self.settingsRepository.Save(ctx, &repository.Settings{
- ShowMode: showMode,
- ShowOwner: showOwner,
+ ShowMode: showMode,
+ ShowOwner: showOwner,
+ PreloadVideoMetadata: preloadVideoMetadata,
})
if err != nil {
return err