@@ -57,7 +57,7 @@ public UserConfig() : base()
5757 {
5858 User = new UiUser ( ) ;
5959 }
60-
60+
6161 private void OnGlobalConfigChange ( Config config , ConfigItem [ ] changedItems )
6262 {
6363 // Get properties that belong to the user config
@@ -74,7 +74,7 @@ private void OnGlobalConfigChange(Config config, ConfigItem[] changedItems)
7474
7575 public async Task SetUserInformation ( string userDn , ApiConnection apiConnection )
7676 {
77- if ( globalConfig != null )
77+ if ( globalConfig != null )
7878 {
7979 OnGlobalConfigChange ( globalConfig , globalConfig . RawConfigItems ) ;
8080 }
@@ -95,11 +95,11 @@ public async Task SetUserInformation(string userDn, ApiConnection apiConnection)
9595
9696 public async Task ChangeLanguage ( string languageName , ApiConnection apiConnection )
9797 {
98- if ( globalConfig != null )
98+ if ( globalConfig != null )
9999 {
100100 await apiConnection . SendQueryAsync < ReturnId > ( AuthQueries . updateUserLanguage , new { id = User . DbId , language = languageName } ) ;
101101 Translate = globalConfig . LangDict [ languageName ] ;
102- Overwrite = apiConnection != null ? await GetCustomDict ( languageName ) : globalConfig . OverDict [ languageName ] ;
102+ Overwrite = apiConnection != null ? await GetCustomDict ( languageName ) : globalConfig . OverDict [ languageName ] ;
103103 User . Language = languageName ;
104104 InvokeOnChange ( this , [ ] ) ;
105105 }
@@ -112,8 +112,12 @@ public string GetUserLanguage()
112112
113113 public void SetLanguage ( string languageName )
114114 {
115- User = new UiUser ( ) { Language = languageName != null && languageName != "" ? languageName :
116- globalConfig != null ? globalConfig . DefaultLanguage : GlobalConst . kEnglish } ;
115+ string defaultLanguage = globalConfig != null ? globalConfig . DefaultLanguage : GlobalConst . kEnglish ;
116+
117+ User = new UiUser ( )
118+ {
119+ Language = languageName != null && languageName != "" ? languageName : defaultLanguage
120+ } ;
117121 if ( globalConfig != null && globalConfig . LangDict . TryGetValue ( User . Language , out Dictionary < string , string > ? langDict ) )
118122 {
119123 Translate = langDict ;
@@ -133,7 +137,7 @@ public override string GetText(string key)
133137 }
134138 else
135139 {
136- if ( globalConfig != null )
140+ if ( globalConfig != null )
137141 {
138142 string defaultLanguage = globalConfig . DefaultLanguage ;
139143 if ( defaultLanguage == "" )
@@ -160,15 +164,15 @@ public string PureLine(string text)
160164
161165 public static string PureLineStat ( string text )
162166 {
163- var regex = new Regex ( @"\s" , RegexOptions . None , TimeSpan . FromSeconds ( 1 ) ) ;
164- string output = RemoveLinks ( regex . Replace ( text . Trim ( ) , " " ) ) ;
167+ var regex = new Regex ( @"\s" , RegexOptions . None , TimeSpan . FromSeconds ( 1 ) ) ;
168+ string output = RemoveLinks ( regex . Replace ( text . Trim ( ) , " " ) ) ;
165169 output = ReplaceListElems ( output ) ;
166170 bool cont = true ;
167- while ( cont )
171+ while ( cont )
168172 {
169173 string outputOrig = output ;
170174 output = Regex . Replace ( outputOrig , @" " , " " ) ;
171- if ( output . Length == outputOrig . Length )
175+ if ( output . Length == outputOrig . Length )
172176 {
173177 cont = false ;
174178 }
@@ -248,7 +252,7 @@ private static string RemoveLinks(string txtString)
248252 txtString = Regex . Replace ( txtString , "</a>" , "" ) ;
249253 return txtString ;
250254 }
251-
255+
252256 private static string ReplaceListElems ( string txtString )
253257 {
254258 txtString = Regex . Replace ( txtString , "<ol>" , "" ) ;
@@ -260,7 +264,7 @@ private static string ReplaceListElems(string txtString)
260264 txtString = Regex . Replace ( txtString , "<br>" , "\r \n " ) ;
261265 return txtString ;
262266 }
263-
267+
264268 private string Convert ( string rawText )
265269 {
266270 string plainText = System . Web . HttpUtility . HtmlDecode ( rawText ) ;
@@ -300,7 +304,13 @@ private string Convert(string rawText)
300304 return plainText ;
301305 }
302306
303- protected virtual void Dispose ( bool disposing )
307+ public new void Dispose ( )
308+ {
309+ Dispose ( disposing : true ) ;
310+ GC . SuppressFinalize ( this ) ;
311+ }
312+
313+ protected override void Dispose ( bool disposing )
304314 {
305315 if ( ! disposedValue )
306316 {
@@ -310,12 +320,7 @@ protected virtual void Dispose(bool disposing)
310320 }
311321 disposedValue = true ;
312322 }
313- }
314-
315- public void Dispose ( )
316- {
317- Dispose ( disposing : true ) ;
318- GC . SuppressFinalize ( this ) ;
323+ base . Dispose ( disposing ) ; // Call base class dispose
319324 }
320325 }
321326}
0 commit comments