fix: BRB backdrop seed replaces existing instead of skipping

SeedBrbBackdrop() now updates the AssetId on an existing Background
source instead of bailing when one already exists. This ensures the
new brb-backdrop.jpg replaces any old image already in the DB.
This commit is contained in:
2026-08-19 15:02:47 -07:00
parent f40ec83e69
commit a76a3d2acd
+18 -8
View File
@@ -1771,7 +1771,6 @@ public class MainViewModel : ViewModelBase
{ {
var brb = Scenes.FirstOrDefault(s => SceneCatalog.Is(s.Name, "BRB")); var brb = Scenes.FirstOrDefault(s => SceneCatalog.Is(s.Name, "BRB"));
if (brb == null) return; if (brb == null) return;
if (brb.Elements.OfType<Source>().Any(s => s.Type == SourceType.Background)) return;
var uri = new Uri("pack://application:,,,/Assets/brb-backdrop.jpg", UriKind.Absolute); var uri = new Uri("pack://application:,,,/Assets/brb-backdrop.jpg", UriKind.Absolute);
using var stream = Application.GetResourceStream(uri)?.Stream; using var stream = Application.GetResourceStream(uri)?.Stream;
@@ -1781,14 +1780,25 @@ public class MainViewModel : ViewModelBase
var bytes = ms.ToArray(); var bytes = ms.ToArray();
var assetId = AddAsset(bytes); var assetId = AddAsset(bytes);
if (assetId == null) return; if (assetId == null) return;
brb.Elements.Add(new Source
var existing = brb.Elements.OfType<Source>().FirstOrDefault(s => s.Type == SourceType.Background);
if (existing != null)
{ {
Name = "Background", existing.AssetId = assetId;
Type = SourceType.Background, existing.Width = 1920;
AssetId = assetId, existing.Height = 1080;
Width = 1920, }
Height = 1080, else
}); {
brb.Elements.Add(new Source
{
Name = "Background",
Type = SourceType.Background,
AssetId = assetId,
Width = 1920,
Height = 1080,
});
}
} }
catch { /* non-critical — stream works fine without a default bg */ } catch { /* non-critical — stream works fine without a default bg */ }
} }