1111using FluentAvalonia . UI . Controls ;
1212using FluentIcons . Common ;
1313using Injectio . Attributes ;
14+ using Microsoft . Extensions . Options ;
1415using OpenIddict . Client ;
1516using StabilityMatrix . Avalonia . Controls ;
1617using StabilityMatrix . Avalonia . Languages ;
2425using StabilityMatrix . Core . Extensions ;
2526using StabilityMatrix . Core . Models . Api ;
2627using StabilityMatrix . Core . Models . Api . Lykos ;
28+ using StabilityMatrix . Core . Models . Configs ;
2729using StabilityMatrix . Core . Processes ;
2830using StabilityMatrix . Core . Services ;
2931using Symbol = FluentIcons . Common . Symbol ;
@@ -42,6 +44,7 @@ public partial class AccountSettingsViewModel : PageViewModelBase
4244 private readonly IServiceManager < ViewModelBase > vmFactory ;
4345 private readonly INotificationService notificationService ;
4446 private readonly ILykosAuthApiV2 lykosAuthApi ;
47+ private readonly IOptions < ApiOptions > apiOptions ;
4548
4649 /// <inheritdoc />
4750 public override string Title => "Accounts" ;
@@ -69,21 +72,24 @@ public partial class AccountSettingsViewModel : PageViewModelBase
6972 [ ObservableProperty ]
7073 private CivitAccountStatusUpdateEventArgs civitStatus = CivitAccountStatusUpdateEventArgs . Disconnected ;
7174
72- public string LykosAccountManageUrl => new Uri ( App . LykosAccountApiBaseUrl ) . Append ( "/manage" ) . ToString ( ) ;
75+ public string LykosAccountManageUrl =>
76+ apiOptions . Value . LykosAccountApiBaseUrl . Append ( "/manage" ) . ToString ( ) ;
7377
7478 public AccountSettingsViewModel (
7579 IAccountsService accountsService ,
7680 ISettingsManager settingsManager ,
7781 IServiceManager < ViewModelBase > vmFactory ,
7882 INotificationService notificationService ,
79- ILykosAuthApiV2 lykosAuthApi
83+ ILykosAuthApiV2 lykosAuthApi ,
84+ IOptions < ApiOptions > apiOptions
8085 )
8186 {
8287 this . accountsService = accountsService ;
8388 this . settingsManager = settingsManager ;
8489 this . vmFactory = vmFactory ;
8590 this . notificationService = notificationService ;
8691 this . lykosAuthApi = lykosAuthApi ;
92+ this . apiOptions = apiOptions ;
8793
8894 accountsService . LykosAccountStatusUpdate += ( _ , args ) =>
8995 {
@@ -128,24 +134,24 @@ private async Task<bool> BeforeConnectCheck()
128134 Title = "About Account Credentials" ,
129135 Content = """
130136 Account credentials and tokens are stored locally on your computer, with at-rest AES encryption.
131-
137+
132138 If you make changes to your computer hardware, you may need to re-login to your accounts.
133-
139+
134140 Account tokens will not be viewable after saving, please make a note of them if you need to use them elsewhere.
135141 """ ,
136142 PrimaryButtonText = Resources . Action_Continue ,
137143 CloseButtonText = Resources . Action_Cancel ,
138144 DefaultButton = ContentDialogButton . Primary ,
139- MaxDialogWidth = 400
145+ MaxDialogWidth = 400 ,
140146 } ;
141147
142148 if ( await dialog . ShowAsync ( ) != ContentDialogResult . Primary )
143149 {
144150 return false ;
145151 }
146152
147- settingsManager . Transaction (
148- s => s . SeenTeachingTips . Add ( TeachingTip . AccountsCredentialsStorageNotice )
153+ settingsManager . Transaction ( s =>
154+ s . SeenTeachingTips . Add ( TeachingTip . AccountsCredentialsStorageNotice )
149155 ) ;
150156 }
151157
@@ -161,7 +167,7 @@ private async Task ConnectLykos()
161167 var vm = vmFactory . Get < OAuthDeviceAuthViewModel > ( ) ;
162168 vm . ChallengeRequest = new OpenIddictClientModels . DeviceChallengeRequest
163169 {
164- ProviderName = OpenIdClientConstants . LykosAccount . ProviderName
170+ ProviderName = OpenIdClientConstants . LykosAccount . ProviderName ,
165171 } ;
166172 await vm . ShowDialogAsync ( ) ;
167173
@@ -236,15 +242,15 @@ private async Task ConnectCivit()
236242 {
237243 throw new ValidationException ( "API key is required" ) ;
238244 }
239- }
240- }
245+ } ,
246+ } ,
241247 } ;
242248
243249 var dialog = DialogHelper . CreateTextEntryDialog (
244250 "Connect CivitAI Account" ,
245251 """
246252 Login to [CivitAI](https://civitai.com/) and head to your [Account](https://civitai.com/user/account) page
247-
253+
248254 Add a new API key and paste it below
249255 """ ,
250256 "avares://StabilityMatrix.Avalonia/Assets/guide-civitai-api.webp" ,
0 commit comments