Repository navigation
|
I see there are three basic governors: Default, NightLight, AmbientLight. But in the code there's often the need to discriminate between LocationTimes and CoordinateTimes. SwitchTriggerMode does have different enums for this, so why does Governor not? switch (_builder.Config.Governor)
{
case Governor.NightLight:
return SwitchTriggerMode.WindowsNightLight;
case Governor.AmbientLight:
return SwitchTriggerMode.AmbientLight;
default:
if (_builder.Config.Location.Enabled)
{
return _builder.Config.Location.UseGeolocatorService ? SwitchTriggerMode.LocationTimes : SwitchTriggerMode.CoordinateTimes;
}
else
{
return SwitchTriggerMode.CustomTimes;
}
}In fact, why can't we use one-and-the-same "thing" for both? I mean, UI and backend should always be in sync, am I right? |
Replies: 1 comment
|
For Sunrise = builder.Config.Sunrise;
Sunset = builder.Config.Sunset;
_adjustedSunrise = Sunrise;
_adjustedSunset = Sunset;
if (builder.Config.Location.Enabled)
{
LocationHandler.GetSunTimes(builder, out _adjustedSunrise, out _adjustedSunset);
}It starts from
|
GovernorandSwitchTriggerModesit at different layers and don't need to carry the same information, that's why the split looks asymmetric.Governor(AutoDarkModeLib/Enums.cs#L91) only picks which engine decides when to switch. There are exactly three governor implementations wired up from it, in GovernorModule.cs#L77-L89:TimeSwitchGovernor,NightLightGovernor,AmbientLightGovernor.For
Governor.Default, TimeSwitchGovernor.Run() doesn't care at all where the sunrise/sunset times came from, it just asks aTimedThemeStatefor the next/current switch time. The actual "custom vs location vs coordinates" branching happens one layer down, inTimedThemeState.Calculate():