Clean up AppPreferences - #4986
Merged
cwisniew merged 3 commits intoOct 9, 2024
Merged
Conversation
This new class is for app state that needs to be maintained between runs of MT. It is not for user preferences despite being built on `Preferences` as well.
All `AppPreferences` preferences will be made instances of this type in the next change. For now, we are just adding the new classes: - `Type<T>` defines how to store the preference. - `Preference<T>` defines the preference itself by its key, type, default value, and validation. - Implementations of `Preference` specialize the storage characteristics, i.e., which methods on the `Preference` object to use when loading and storing a value.
All preferences are now instances of `Preference<T>`. The few types that had additional update logic not use the change listener to notify observers about it. In order to really make this change effective, we no longer store any colors component-wise since they can easily be stored as a single integer. For those preferences that once had component-wise storage, the static initializer ensures backwards compatibility by detecting whether a new value is present and loading the old values if not.
kwvanderlinde
force-pushed
the
refactor/4985-app-preferences
branch
from
October 8, 2024 04:25
0131f67 to
110e1e6
Compare
cwisniew
approved these changes
Oct 9, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Identify the Bug or Feature request
Resolves #4985
Description of the Change
This add a new
AppPreferences.Preference<T>type to represent user preferences. Preferences are defined by instantiatng this class and assigning to a static field ofAppPreferences.A new
AppStatePersistedcaptures those parts ofAppPReferencesthat are not related to user preference but are actually about tracking application state across runs of MT. These have more specialized logic as well, so they do not use the new preference types.That sums up the bulk of the changes, but a couple tweaks were made beyond that:
typingNotificationDurationpreference was reduced from 5000 seconds to 5 seconds.ChatAutoSaveis no longer a single with a static interface. Instead, we just choose to create only one inMapTooland interact with it normally.Possible Drawbacks
Assuming no typos in the new preference spellings, should be none.
Documentation Notes
N/A
Release Notes
AppPreferencesto be more declarative.This change is