Skip to content

Conversation

@ghost1372
Copy link
Contributor

@ghost1372 ghost1372 commented Jul 30, 2025

This PR replaces the legacy ApplicationData-based settings system with a new AppConfig class that serializes settings to JSON files. It introduces support for both packaged and unpackaged app scenarios.

Closes #1924.

Old Settings System:

appData.LocalSettings.Values[SettingsKeys.IsLeftMode] = true;

New Settings System:

SettingsHelper.Config.IsLeftMode = true;
SettingsHelper.Save();
image

Description

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Replaces the previous ApplicationData-based settings management with a new AppConfig class that serializes settings to JSON files. Updates all settings access throughout the app to use the new SettingsHelper.Config object, removes SettingsKeys, and introduces extension methods for managing favorites and recently visited items. This change improves settings portability and maintainability, and prepares for future extensibility.
@marcelwgn marcelwgn self-assigned this Jul 30, 2025
@ghost1372 ghost1372 mentioned this pull request Aug 1, 2025
3 tasks
Copy link
Contributor

@Zakariathr22 Zakariathr22 left a comment

Choose a reason for hiding this comment

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

Just a few suggested changes:
Also, I don't think there's any need to save MaxRecentlyVisitedSamples and MaxFavoriteSamples in the local JSON file.

Image

Comment on lines +49 to +52
/// <summary>
/// Gets or sets the maximum number of favorite samples allowed.
/// </summary>
public int MaxFavoriteSamples { get; set; } = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no maximum for the favorite samples. The old logic assumed that if the maximum was set to 0, it meant there was no limit. Since that logic has been removed, we no longer need this.

/// <summary>
/// Represents the maximum number of recently visited samples to retain.
/// </summary>
public int MaxRecentlyVisitedSamples { get; set; } = 7;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public int MaxRecentlyVisitedSamples { get; set; } = 7;
public const int MaxRecentlyVisitedSamples { get; set; } = 7;

This is supposed to be a constant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Zakariathr22
If we decide to exclude the max properties from the JSON file, we should move those properties out of AppConfig.cs and into the SettingsHelper.cs class.
so this suggestion can not be commited here.

@ghost1372
Copy link
Contributor Author

Just a few suggested changes: Also, I don't think there's any need to save MaxRecentlyVisitedSamples and MaxFavoriteSamples in the local JSON file.

Image

Thanks, @Zakariathr22 . I don’t have any issues with that, but let’s check with @marcelwgn as well.
Should we remove the max properties from the JSON file?

Copy link
Contributor

@Zakariathr22 Zakariathr22 left a comment

Choose a reason for hiding this comment

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

FYI, even the Scratchpad uses the legacy ApplicationData-based settings system, so we need to save the code in the local JSON file.

@marcelwgn
Copy link
Contributor

After internal discussion, we decided that we want to stick with the ApplicationData as the default mechanism and fall back to JSON if we are running unpackaged, sorry for the change of direction here. For this, I think we should have a common "IPersistenceProvider"/"ISettingsProvider" interface that depending on the packaging mode gets filled by an ApplicationData or JSON file based provider.

I agree with @Zakariathr22 that MaxRecentlyVisitedSamples and MaxFavoriteSamples should not be persisted, those are policies and not settings.

@ghost1372
Copy link
Contributor Author

After internal discussion, we decided that we want to stick with the ApplicationData as the default mechanism and fall back to JSON if we are running unpackaged, sorry for the change of direction here. For this, I think we should have a common "IPersistenceProvider"/"ISettingsProvider" interface that depending on the packaging mode gets filled by an ApplicationData or JSON file based provider.

I agree with @Zakariathr22 that MaxRecentlyVisitedSamples and MaxFavoriteSamples should not be persisted, those are policies and not settings.

Okay, I think it's better to close this one and open a new PR with the requested changes.

@ghost1372
Copy link
Contributor Author

I'm closing this PR and have opened a new one with the requested changes.

#2014

@ghost1372 ghost1372 closed this Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UnPackaged Mode is Broken

4 participants