From 2fa30379ad4dc989d31c6743711e5d7744fbd3d8 Mon Sep 17 00:00:00 2001 From: Quick <31828688+Quick104@users.noreply.github.com> Date: Mon, 8 Jun 2026 22:36:07 -0400 Subject: [PATCH] fix(jellycompat): include Wholphin display preference dimensions (#102) --- internal/jellycompat/handlers_displayprefs.go | 22 ++++++++------- .../jellycompat/handlers_displayprefs_test.go | 27 +++++++++++++++++++ 2 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 internal/jellycompat/handlers_displayprefs_test.go diff --git a/internal/jellycompat/handlers_displayprefs.go b/internal/jellycompat/handlers_displayprefs.go index 12a319ef..51e24e5a 100644 --- a/internal/jellycompat/handlers_displayprefs.go +++ b/internal/jellycompat/handlers_displayprefs.go @@ -14,16 +14,18 @@ import ( // displayPreferencesDTO mirrors Jellyfin's DisplayPreferences response. type displayPreferencesDTO struct { - ID string `json:"Id"` - SortBy string `json:"SortBy"` - SortOrder string `json:"SortOrder"` - RememberIndexing bool `json:"RememberIndexing"` - RememberSorting bool `json:"RememberSorting"` - ScrollDirection string `json:"ScrollDirection"` - ShowBackdrop bool `json:"ShowBackdrop"` - ShowSidebar bool `json:"ShowSidebar"` - Client string `json:"Client"` - CustomPrefs map[string]string `json:"CustomPrefs"` + ID string `json:"Id"` + SortBy string `json:"SortBy"` + SortOrder string `json:"SortOrder"` + RememberIndexing bool `json:"RememberIndexing"` + RememberSorting bool `json:"RememberSorting"` + ScrollDirection string `json:"ScrollDirection"` + ShowBackdrop bool `json:"ShowBackdrop"` + ShowSidebar bool `json:"ShowSidebar"` + PrimaryImageHeight int `json:"PrimaryImageHeight"` + PrimaryImageWidth int `json:"PrimaryImageWidth"` + Client string `json:"Client"` + CustomPrefs map[string]string `json:"CustomPrefs"` } // DisplayPreferencesHandler serves Jellyfin display preferences endpoints, diff --git a/internal/jellycompat/handlers_displayprefs_test.go b/internal/jellycompat/handlers_displayprefs_test.go new file mode 100644 index 00000000..e06709e6 --- /dev/null +++ b/internal/jellycompat/handlers_displayprefs_test.go @@ -0,0 +1,27 @@ +package jellycompat + +import ( + "encoding/json" + "testing" +) + +func TestDefaultDisplayPreferencesIncludesRequiredImageDimensions(t *testing.T) { + dto := defaultDisplayPreferences("default", "Wholphin") + + body, err := json.Marshal(dto) + if err != nil { + t.Fatalf("marshal default display preferences: %v", err) + } + + var raw map[string]any + if err := json.Unmarshal(body, &raw); err != nil { + t.Fatalf("unmarshal default display preferences: %v", err) + } + + if _, ok := raw["PrimaryImageHeight"]; !ok { + t.Fatal("PrimaryImageHeight missing from display preferences JSON") + } + if _, ok := raw["PrimaryImageWidth"]; !ok { + t.Fatal("PrimaryImageWidth missing from display preferences JSON") + } +}