Skip to content

Conversation

@Jaylyn-Barbee
Copy link
Contributor

@Jaylyn-Barbee Jaylyn-Barbee commented Oct 23, 2025

Summary of the Pull Request

Issue: Currently we are doing the same work twice on first start up of Powertoys.

  1. We check if today = the last updated day and if not we update the sun times.
  2. We also then check if any settings have changed and if so, we update sun times.

If this is a fresh start, the service will have no values to compare to so it will hit point 1 because it will always appear to be a new day if the service just started and also point 2 since there is no "prev" values to compare to.

Fix: added a guard to skip point 2 on a fresh start (ie: g_lastUpdatedDay == -1) which allows the start-up logic to handle this update while still allowing for an update in settings to trigger a sun times update later in the life cycle if needed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR eliminates redundant sun time calculations during PowerToys startup by preventing duplicate work when both the "new day" check and "settings changed" check would trigger simultaneously on first launch.

Key Changes:

  • Initializes previous settings state before the initial theme application
  • Guards the coordinates change detection to skip on first run (when g_lastUpdatedDay == -1)

settings.scheduleMode == ScheduleMode::SunsetToSunrise);
bool coordsChanged = (prevLat != settings.latitude || prevLon != settings.longitude);

// ensures that coordsChanged is false on first run (since we already did this work below)
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment references 'this work below', but the initial sun time calculation happens above at lines 224-241. The comment should say 'above' instead of 'below' to accurately reflect the code location.

Suggested change
// ensures that coordsChanged is false on first run (since we already did this work below)
// ensures that coordsChanged is false on first run (since we already did this work above)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant