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
+11 -1
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,6 +1780,16 @@ 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;
var existing = brb.Elements.OfType<Source>().FirstOrDefault(s => s.Type == SourceType.Background);
if (existing != null)
{
existing.AssetId = assetId;
existing.Width = 1920;
existing.Height = 1080;
}
else
{
brb.Elements.Add(new Source brb.Elements.Add(new Source
{ {
Name = "Background", Name = "Background",
@@ -1790,6 +1799,7 @@ public class MainViewModel : ViewModelBase
Height = 1080, Height = 1080,
}); });
} }
}
catch { /* non-critical — stream works fine without a default bg */ } catch { /* non-critical — stream works fine without a default bg */ }
} }