Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Emby/Emby.Plugins.Moonfin/Pages/moonfin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 = {
Expand Down
5 changes: 3 additions & 2 deletions Jellyfin/backend/Pages/configPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -1983,13 +1983,13 @@ <h3 class="sectionTitle">Active Downloads</h3>
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,
Expand All @@ -1998,6 +1998,7 @@ <h3 class="sectionTitle">Active Downloads</h3>
pluginDisplayText: section.pluginDisplayText || section.pluginSection || 'Dynamic row'
};
} else {
if (section.enabled === false) return;
var definition = homeSectionDefinition(section.type);
if (!definition) return;
normalized = {
Expand Down
52 changes: 52 additions & 0 deletions Jellyfin/backend/Services/MoonfinSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<MoonfinHomeSectionConfig>();

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<MoonfinHomeSectionConfig>();
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
});
}
}
}
}

/// <summary>
/// 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
Expand Down
Loading