Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitced517e

Browse files
committed
PR adjustments
1 parente7b2491 commitced517e

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

‎App/Services/SettingsManager.cs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
usingGoogle.Protobuf.WellKnownTypes;
2+
usingSerilog;
23
usingSystem;
34
usingSystem.Collections.Generic;
45
usingSystem.IO;
@@ -30,11 +31,6 @@ namespace Coder.Desktop.App.Services;
3031
/// <param name="ct"></param>
3132
/// <returns></returns>
3233
publicTaskWrite(Tsettings,CancellationTokenct=default);
33-
/// <summary>
34-
/// Returns null if the settings are not cached or not available.
35-
/// </summary>
36-
/// <returns></returns>
37-
publicT?GetFromCache();
3834
}
3935

4036
/// <summary>
@@ -80,6 +76,12 @@ public SettingsManager(string? settingsFilePath = null)
8076

8177
publicasyncTask<T>Read(CancellationTokenct=default)
8278
{
79+
if(_cachedSettingsis notnull)
80+
{
81+
// return cached settings if available
82+
return(T)_cachedSettings.Clone();
83+
}
84+
8385
// try to get the lock with short timeout
8486
if(!await_gate.WaitAsync(LockTimeout,ct).ConfigureAwait(false))
8587
thrownewInvalidOperationException(
@@ -145,41 +147,39 @@ await File.WriteAllTextAsync(_settingsFilePath, json, ct)
145147
_gate.Release();
146148
}
147149
}
148-
149-
publicT?GetFromCache()
150-
{
151-
return_cachedSettings;
152-
}
153150
}
154151

155152
publicinterfaceISettings
156153
{
157154
/// <summary>
158-
///Gets the version ofthe settingsschema.
155+
///FileName wherethe settingsare stored.
159156
/// </summary>
160-
intVersion{get;}
157+
staticabstractstringSettingsFileName{get;}
161158

162159
/// <summary>
163-
///FileName wherethe settingsare stored.
160+
///Gets the version ofthe settingsschema.
164161
/// </summary>
165-
staticabstractstringSettingsFileName{get;}
162+
intVersion{get;}
163+
164+
ISettingsClone();
166165
}
167166

168167
/// <summary>
169168
/// CoderConnect settings class that holds the settings for the CoderConnect feature.
170169
/// </summary>
171170
publicclassCoderConnectSettings:ISettings
172171
{
172+
publicstaticstringSettingsFileName{get;}="coder-connect-settings.json";
173+
publicintVersion{get;set;}
174+
publicboolConnectOnLaunch{get;set;}
175+
173176
/// <summary>
174-
/// CoderConnect settings version. Increment this when the settings schema changes.
177+
/// CoderConnectcurrentsettings version. Increment this when the settings schema changes.
175178
/// In future iterations we will be able to handle migrations when the user has
176179
/// an older version.
177180
/// </summary>
178-
publicintVersion{get;set;}
179-
publicboolConnectOnLaunch{get;set;}
180-
publicstaticstringSettingsFileName{get;}="coder-connect-settings.json";
181+
privateconstintVERSION=1;
181182

182-
privateconstintVERSION=1;// Default version for backward compatibility
183183
publicCoderConnectSettings()
184184
{
185185
Version=VERSION;
@@ -192,10 +192,13 @@ public CoderConnectSettings(int? version, bool connectOnLogin)
192192
ConnectOnLaunch=connectOnLogin;
193193
}
194194

195+
ISettingsISettings.Clone()
196+
{
197+
returnClone();
198+
}
199+
195200
publicCoderConnectSettingsClone()
196201
{
197202
returnnewCoderConnectSettings(Version,ConnectOnLaunch);
198203
}
199-
200-
201204
}

‎App/ViewModels/SettingsViewModel.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ public SettingsViewModel(ILogger<SettingsViewModel> logger, ISettingsManager<Cod
3131
_logger=logger;
3232
// Application settings are loaded on application startup,
3333
// so we expect the settings to be available immediately.
34-
varsettingsCache=settingsManager.GetFromCache();
35-
if(settingsCacheis notnull)
36-
{
37-
_connectSettings=settingsCache.Clone();
38-
}
34+
varsettingsCache=settingsManager.Read();
3935
StartOnLogin=startupManager.IsEnabled();
4036
ConnectOnLaunch=_connectSettings.ConnectOnLaunch;
4137

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp