@@ -26,22 +26,20 @@ namespace Biyori.Settings.Frames
26
26
/// </summary>
27
27
public partial class SettingsPage_Accounts : Page
28
28
{
29
- private SettingsProvider settingsProvider { get => App . ServiceProvider . GetProvider < SettingsProvider > ( ) ; }
29
+ private SettingsProviderService settingsProvider { get => App . ServiceProvider . GetProvider < SettingsProviderService > ( ) ; }
30
30
private AccountSettings accountSettings { get => this . settingsProvider . GetConfig < AccountSettings > ( ) ; }
31
31
private List < AccountInfo > _accountInfo { get => this . settingsProvider . GetConfig < AccountSettings > ( ) ? . Accounts ; }
32
32
public List < AccountInfo > accountInfo { get ; set ; } = new List < AccountInfo > ( ) ;
33
- [ AlsoNotifyFor ( "selectedAccountShow" ) ]
34
- public AccountInfo selectedAccount { get => this . accountSettings . CurrentAccount ; set {
35
- var s = this . accountSettings ;
36
- s . CurrentAccount = value ;
37
- this . settingsProvider . UpdateConfig < AccountSettings > ( s ) ;
38
- } }
33
+ [ AlsoNotifyFor ( "selectedAccountShow" , "DataChanged" ) ]
34
+ public AccountInfo selectedAccount { get ; set ; }
39
35
public Visibility selectedAccountShow { get => this . selectedAccount != null ? Visibility . Visible : Visibility . Hidden ; }
36
+ public bool DataChanged { get => this . selectedAccount ? . ProfileHash != this . accountSettings . CurrentAccount ? . ProfileHash ; }
40
37
public SettingsPage_Accounts ( )
41
38
{
42
39
InitializeComponent ( ) ;
43
40
this . accountInfo . Clear ( ) ;
44
41
this . accountInfo = _accountInfo ;
42
+ this . selectedAccount = this . accountSettings . CurrentAccount ;
45
43
}
46
44
47
45
private void AccountSelection_Click ( object sender , RoutedEventArgs e )
@@ -51,6 +49,14 @@ private void AccountSelection_Click(object sender, RoutedEventArgs e)
51
49
this . selectedAccount = ( sender as Button ) ? . DataContext as AccountInfo ;
52
50
} ) ) ;
53
51
}
52
+ private void AccountSelection_Save ( object sender , RoutedEventArgs e )
53
+ {
54
+ Dispatcher . BeginInvoke ( ( Action ) ( ( ) =>
55
+ {
56
+ this . accountSettings . CurrentAccount = this . selectedAccount ;
57
+ this . settingsProvider . UpdateConfig ( this . accountSettings ) ;
58
+ } ) ) ;
59
+ }
54
60
}
55
61
[ SettingsSection ( "account" , true ) ]
56
62
public class AccountSettings : SettingsBase
@@ -74,6 +80,8 @@ public class AccountInfo
74
80
public AccountEndpoints Type { get ; set ; } = AccountEndpoints . Kitsu ;
75
81
[ JsonIgnore ]
76
82
public string TypeString { get => this . Type . ToString ( ) ; }
83
+ [ JsonIgnore ]
84
+ public string ProfileHash { get => this . Username ? . GetHashCode ( ) . ToString ( "X8" ) ; }
77
85
}
78
86
public enum AccountEndpoints
79
87
{
0 commit comments