74bcb91b65
When the user edits their active custom theme JSON in an external editor and saves, the change now propagates to HellionChat within ~1 second without re-selecting the theme in the picker. RefreshActiveIfStale runs from Plugin.Draw on every frame but the actual File.GetLastWriteTimeUtc stat is 1Hz-throttled -- 60fps would otherwise mean 3600 stats/min, more on Wine. Built-in themes short-circuit on the IsBuiltIn check; custom themes without a captured source path (Switch fell to default) short-circuit on the null check. Switch() now captures the source path of custom themes via an out-param on LoadCustomBySlug, which now reverse-looks-up against the existing _customCache (no re-parse, no extra disk IO). Plugin.LoadAsync warms the cache via AllCustom() once before the first Switch so a Config.Theme pointing at a custom slug does not fall through to the built-in default on a cold registry. Switch's lookup order is now built-in-first to match Get(slug), so a user-authored JSON that declares a built-in slug is consistently ignored in both code paths. Pure-helper ThemeStampDiff isolates the stamp-diff rules for the Build-Suite (covers DateTime.MinValue hold-the-line semantics). v1.4.8 B2.
21 lines
851 B
C#
21 lines
851 B
C#
namespace HellionChat.Themes;
|
|
|
|
// Pure stale-check for the v1.4.8 B2 theme-auto-refresh-on-active path.
|
|
// Lives in a free helper class so the Build-Suite can exercise the diff
|
|
// rules without instantiating ThemeRegistry (which touches the Dalamud
|
|
// log proxy and the filesystem). The rules:
|
|
// - DateTime.MinValue on the current stat means we could not read the
|
|
// file -- hold the last known good (return false).
|
|
// - Equal stamps mean no change since we last saw it.
|
|
// - Any other difference, including the first observation where lastSeen
|
|
// is MinValue, counts as stale and triggers a reload.
|
|
internal static class ThemeStampDiff
|
|
{
|
|
public static bool IsStale(System.DateTime lastSeen, System.DateTime current)
|
|
{
|
|
if (current == System.DateTime.MinValue)
|
|
return false;
|
|
return current != lastSeen;
|
|
}
|
|
}
|