mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-29 16:08:15 +08:00
fix FirstLoadedAuthenticatorsEmpty
This commit is contained in:
@@ -43,8 +43,13 @@ namespace System.Application.Services
|
||||
await InitializeAsync(auths, isSync);
|
||||
}
|
||||
|
||||
public async Task InitializeAsync(GameAccountPlatformAuthenticator[] auths, bool isSync = false)
|
||||
public async Task InitializeAsync(GameAccountPlatformAuthenticator[] auths, bool isSync = false, Action? emptyAction = null)
|
||||
{
|
||||
if (!auths.Any_Nullable())
|
||||
{
|
||||
emptyAction?.Invoke();
|
||||
return;
|
||||
}
|
||||
var hasPassword = repository.HasSecondaryPassword(auths);
|
||||
List<IGAPAuthenticatorDTO> list;
|
||||
if (hasPassword)
|
||||
@@ -81,7 +86,7 @@ namespace System.Application.Services
|
||||
// ToastService.Current.Notify(AppResources.LocalAuth_RefreshAuthSuccess);
|
||||
});
|
||||
}
|
||||
else if (auths.Any_Nullable() && !list.Any_Nullable())
|
||||
else
|
||||
{
|
||||
Toast.Show(AppResources.LocalAuth_ProtectionAuth_PasswordError);
|
||||
}
|
||||
|
||||
@@ -99,6 +99,15 @@ namespace System.Application.UI.ViewModels
|
||||
|
||||
public ReactiveCommand<Unit, Unit> RefreshAuthCommand { get; }
|
||||
|
||||
#if __MOBILE__
|
||||
private bool _IsFirstLoadedAuthenticatorsEmpty;
|
||||
public bool IsFirstLoadedAuthenticatorsEmpty
|
||||
{
|
||||
get => _IsFirstLoadedAuthenticatorsEmpty;
|
||||
set => this.RaiseAndSetIfChanged(ref _IsFirstLoadedAuthenticatorsEmpty, value);
|
||||
}
|
||||
#endif
|
||||
|
||||
public async override void Activation()
|
||||
{
|
||||
var auths = await AuthService.Current.Repository.GetAllSourceAsync();
|
||||
@@ -108,7 +117,14 @@ namespace System.Application.UI.ViewModels
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
await AuthService.Current.InitializeAsync(auths);
|
||||
await AuthService.Current.InitializeAsync(auths
|
||||
#if __MOBILE__
|
||||
, emptyAction: () =>
|
||||
{
|
||||
IsFirstLoadedAuthenticatorsEmpty = true;
|
||||
}
|
||||
#endif
|
||||
);
|
||||
});
|
||||
}
|
||||
base.Activation();
|
||||
|
||||
@@ -37,11 +37,11 @@ namespace System.Application.UI.Fragments
|
||||
speedDialDict.ReplaceLabels(ToString2);
|
||||
}).AddTo(this);
|
||||
|
||||
ViewModel!.WhenAnyValue(x => x.IsAuthenticatorsEmpty).Subscribe(value =>
|
||||
void OnAuthenticatorsChanged(bool isAuthenticatorsEmpty, bool isFirstActivation)
|
||||
{
|
||||
if (binding == null) return;
|
||||
ViewStates state, state_reverse, fab_state, loading_state;
|
||||
if (ViewModel!.IsFirstActivation)
|
||||
if (isFirstActivation)
|
||||
{
|
||||
state = ViewStates.Gone;
|
||||
state_reverse = ViewStates.Gone;
|
||||
@@ -50,8 +50,8 @@ namespace System.Application.UI.Fragments
|
||||
}
|
||||
else
|
||||
{
|
||||
state = value ? ViewStates.Visible : ViewStates.Gone;
|
||||
state_reverse = !value ? ViewStates.Visible : ViewStates.Gone;
|
||||
state = isAuthenticatorsEmpty ? ViewStates.Visible : ViewStates.Gone;
|
||||
state_reverse = !isAuthenticatorsEmpty ? ViewStates.Visible : ViewStates.Gone;
|
||||
fab_state = ViewStates.Visible;
|
||||
loading_state = ViewStates.Gone;
|
||||
}
|
||||
@@ -59,7 +59,14 @@ namespace System.Application.UI.Fragments
|
||||
binding.rvAuthenticators.Visibility = state_reverse;
|
||||
binding.speedDial.Visibility = fab_state;
|
||||
binding.layoutLoading.Visibility = loading_state;
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
ViewModel!.WhenAnyValue(x => x.IsAuthenticatorsEmpty)
|
||||
.Subscribe(x => OnAuthenticatorsChanged(x, ViewModel!.IsFirstActivation))
|
||||
.AddTo(this);
|
||||
ViewModel!.WhenAnyValue(x => x.IsFirstLoadedAuthenticatorsEmpty)
|
||||
.Subscribe(x => OnAuthenticatorsChanged(ViewModel!.IsAuthenticatorsEmpty, x))
|
||||
.AddTo(this);
|
||||
|
||||
var adapter = new GAPAuthenticatorAdapter(this, ViewModel!);
|
||||
adapter.ItemClick += (_, e) =>
|
||||
|
||||
Reference in New Issue
Block a user