diff --git a/Emby/Emby.Plugins.Moonfin/Pages/moonfin.js b/Emby/Emby.Plugins.Moonfin/Pages/moonfin.js index 14ea9d5..325d6d2 100644 --- a/Emby/Emby.Plugins.Moonfin/Pages/moonfin.js +++ b/Emby/Emby.Plugins.Moonfin/Pages/moonfin.js @@ -751,13 +751,13 @@ define(['baseView', 'loading', 'emby-input', 'emby-button', 'emby-checkbox', 'em source.slice().sort(function (a, b) { return (a.order == null ? 0 : a.order) - (b.order == null ? 0 : b.order); }).forEach(function (section) { - if (!section || section.enabled === false) return; + if (!section) return; var normalized; if (section.kind === 'pluginDynamic') { normalized = { kind: 'pluginDynamic', type: 'none', - enabled: true, + enabled: section.enabled !== false, order: ordered.length, serverId: section.serverId || '', pluginSource: section.pluginSource || 'hss', @@ -766,6 +766,7 @@ define(['baseView', 'loading', 'emby-input', 'emby-button', 'emby-checkbox', 'em pluginDisplayText: section.pluginDisplayText || section.pluginSection || 'Dynamic row' }; } else { + if (section.enabled === false) return; var definition = homeSectionDefinition(section.type); if (!definition) return; normalized = { diff --git a/Jellyfin/backend/Pages/configPage.html b/Jellyfin/backend/Pages/configPage.html index d20e4e1..3bfa830 100644 --- a/Jellyfin/backend/Pages/configPage.html +++ b/Jellyfin/backend/Pages/configPage.html @@ -1983,13 +1983,13 @@

Active Downloads

source.slice().sort(function(a, b) { return (a.order == null ? 0 : a.order) - (b.order == null ? 0 : b.order); }).forEach(function(section) { - if (!section || section.enabled === false) return; + if (!section) return; var normalized; if (section.kind === 'pluginDynamic') { normalized = { kind: 'pluginDynamic', type: 'none', - enabled: true, + enabled: section.enabled !== false, order: ordered.length, serverId: section.serverId || '', pluginSource: section.pluginSource, @@ -1998,6 +1998,7 @@

Active Downloads

pluginDisplayText: section.pluginDisplayText || section.pluginSection || 'Dynamic row' }; } else { + if (section.enabled === false) return; var definition = homeSectionDefinition(section.type); if (!definition) return; normalized = { diff --git a/Jellyfin/backend/Services/MoonfinSettingsService.cs b/Jellyfin/backend/Services/MoonfinSettingsService.cs index 357bc49..a5dfa33 100644 --- a/Jellyfin/backend/Services/MoonfinSettingsService.cs +++ b/Jellyfin/backend/Services/MoonfinSettingsService.cs @@ -241,6 +241,7 @@ public async Task SaveUserSettingsAsync(Guid userId, MoonfinUserSettings setting finalSettings.SchemaVersion = 2; MoveContentHidingToGlobal(finalSettings); + PropagateCustomHomeSectionsAcrossProfiles(finalSettings); var json = JsonSerializer.Serialize(finalSettings, _jsonOptions); AtomicFile.WriteAllText(filePath, json); @@ -293,6 +294,7 @@ public async Task SaveProfileAsync( settings.SchemaVersion = 2; MoveContentHidingToGlobal(settings); + PropagateCustomHomeSectionsAcrossProfiles(settings); var serialized = JsonSerializer.Serialize(settings, _jsonOptions); AtomicFile.WriteAllText(filePath, serialized); @@ -661,9 +663,59 @@ private MoonfinUserSettings MergeSettings(MoonfinUserSettings? existing, Moonfin } } + PropagateCustomHomeSectionsAcrossProfiles(existing); return existing; } + private static void PropagateCustomHomeSectionsAcrossProfiles(MoonfinUserSettings settings) + { + var profiles = new[] { settings.Global, settings.Desktop, settings.Mobile, settings.Tv }; + var allCustomSections = new List(); + + foreach (var profile in profiles) + { + if (profile?.HomeSections == null) continue; + foreach (var section in profile.HomeSections) + { + if (string.Equals(section.Kind, "pluginDynamic", StringComparison.OrdinalIgnoreCase) && + string.Equals(section.PluginSource, "custom", StringComparison.OrdinalIgnoreCase) && + !string.IsNullOrWhiteSpace(section.PluginSection)) + { + if (!allCustomSections.Any(s => string.Equals(s.PluginSection, section.PluginSection, StringComparison.OrdinalIgnoreCase))) + { + allCustomSections.Add(section); + } + } + } + } + + if (allCustomSections.Count == 0) return; + + foreach (var profile in profiles) + { + if (profile == null) continue; + profile.HomeSections ??= new List(); + foreach (var custom in allCustomSections) + { + if (!profile.HomeSections.Any(s => string.Equals(s.PluginSection, custom.PluginSection, StringComparison.OrdinalIgnoreCase))) + { + profile.HomeSections.Add(new MoonfinHomeSectionConfig + { + Kind = "pluginDynamic", + Type = "none", + Enabled = false, + Order = profile.HomeSections.Count, + ServerId = string.IsNullOrWhiteSpace(custom.ServerId) ? "custom" : custom.ServerId, + PluginSource = "custom", + PluginSection = custom.PluginSection, + PluginAdditionalData = custom.PluginAdditionalData, + PluginDisplayText = custom.PluginDisplayText + }); + } + } + } + } + /// /// Resets every server user to a clean settings file containing only a global profile /// equal to the supplied admin defaults. Existing device profiles and personal