Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transitioned to Json Settings #6113

Merged
merged 34 commits into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
82ebfc9
BaseJsonSettingsModel v3 test
d2dyno1 Sep 13, 2021
7cc8a70
Showcase of ISettingsSharingContext
d2dyno1 Sep 13, 2021
707a5db
Transfer more settings into new format
d2dyno1 Sep 15, 2021
57a3342
Transition more settings and added settings merger
d2dyno1 Sep 15, 2021
230239f
Fixed UI not being updated after a setting is changed
d2dyno1 Sep 15, 2021
d0ceec8
Hopefully fix OnSettingChangedEvent not being raised
d2dyno1 Sep 16, 2021
fb0fa9d
Added back caching feature to Bundles
d2dyno1 Sep 16, 2021
7f47567
Fix build
d2dyno1 Sep 16, 2021
5f9fdf1
Remove some stuff from old SettingsViewModel
d2dyno1 Sep 16, 2021
7bfeeba
Added missing service registration StartupSettingsService
gave92 Sep 19, 2021
81ce4fc
Removed ported settings definitions from SettingsViewModel
gave92 Sep 19, 2021
98ea1c9
Add back AppCenter logging for settings
gave92 Sep 19, 2021
004a103
Merged even more settings
d2dyno1 Sep 19, 2021
a416b02
Merge remote-tracking branch 'upstream/main' into iusersettings
d2dyno1 Sep 19, 2021
f419fc8
Fix file tag selection
gave92 Sep 19, 2021
4e042ea
Merge branch 'iusersettings' of https://github.com/d2dyno1/Files into…
gave92 Sep 19, 2021
a82b3db
Use TValue type for defaultValue
d2dyno1 Sep 19, 2021
3355da1
Added IFileTagsSettingsService
d2dyno1 Sep 19, 2021
d92b402
Added IBundlesSettingsService
d2dyno1 Sep 19, 2021
32a40b5
Fix InvalidCastException
gave92 Sep 19, 2021
259af5d
Merge branch 'iusersettings' of https://github.com/d2dyno1/Files into…
gave92 Sep 19, 2021
e95ed78
Resolve conflicts
d2dyno1 Sep 27, 2021
ae9af73
Merge branch 'iusersettings' of https://github.com/d2dyno1/Files into…
d2dyno1 Sep 27, 2021
29c471c
Fix conflicts
d2dyno1 Oct 1, 2021
160a974
Fix 1
d2dyno1 Oct 1, 2021
d23d911
Fix 2
d2dyno1 Oct 1, 2021
f0af6df
Merge branch 'main' into iusersettings
d2dyno1 Oct 5, 2021
b6c6889
Merge remote-tracking branch 'upstream/main' into iusersettings
d2dyno1 Oct 6, 2021
47dcf6d
Fixed changing settings not updating the UI
d2dyno1 Oct 6, 2021
0bce908
Fix build
d2dyno1 Oct 6, 2021
e054723
Fix IsVerticalTabFlyoutEnabled
d2dyno1 Oct 6, 2021
d17e216
Fix NRE
d2dyno1 Oct 6, 2021
d042b20
Fix startup issue
d2dyno1 Oct 6, 2021
d0b2b52
Merge branch 'iusersettings' of https://github.com/d2dyno1/Files into…
d2dyno1 Oct 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Files/Models/JsonSettings/BaseJsonSettingsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ protected virtual TValue Get<TValue>(TValue defaultValue, [CallerMemberName] str
return defaultValue;
}

object value = JsonSettingsDatabase.GetValue(propertyName, defaultValue);

return value is JToken jTokenValue ? jTokenValue.ToObject<TValue>() : (TValue)value;
return JsonSettingsDatabase.GetValue<TValue>(propertyName, defaultValue);
}

protected virtual bool Set<TValue>(TValue value, [CallerMemberName] string propertyName = "")
Expand Down
2 changes: 2 additions & 0 deletions Files/Models/JsonSettings/IJsonSettingsDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ public interface IJsonSettingsDatabase
{
object GetValue(string key, object defaultValue = null);

TValue GetValue<TValue>(string key, object defaultValue = null);

bool AddKey(string key, object value);

bool RemoveKey(string key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ public CachingJsonSettingsDatabase(IJsonSettingsSerializer jsonSettingsSerialize
{
}

public override TValue GetValue<TValue>(string key, object defaultValue = null)
{
if (settingsCache.ContainsKey(key))
{
var value = settingsCache[key];
if (value is Newtonsoft.Json.Linq.JToken jTokenValue)
{
var objValue = jTokenValue.ToObject<TValue>();
settingsCache[key] = objValue;
gave92 marked this conversation as resolved.
Show resolved Hide resolved
return objValue;
}
return (TValue)value;
}
else
{
_cacheMisses++;
return base.GetValue<TValue>(key, defaultValue);
}
}

public override object GetValue(string key, object defaultValue = null)
{
if (settingsCache.ContainsKey(key))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ protected virtual bool SaveSettingsCache()
return settingsSerializer.WriteToFile(settingsData);
}

public virtual TValue GetValue<TValue>(string key, object defaultValue = null)
{
var value = GetValue(key, defaultValue);
if (value is Newtonsoft.Json.Linq.JToken jTokenValue)
{
return jTokenValue.ToObject<TValue>();
}
return (TValue)value;
}

public virtual object GetValue(string key, object defaultValue = null)
{
this.settingsCache = GetNewSettingsCache();
Expand Down