Skip to content

Commit

Permalink
🚧 🐛 修复账号切换某些情况下切换后仍需要登录问题
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbadmin committed Oct 18, 2023
1 parent a6a45e5 commit bfd6b82
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,27 @@ public class SteamDetailPageViewModel : ViewModelBase

public SteamDetailPageViewModel(IAuthenticatorDTO authenticatorDto)
{
if (authenticatorDto.Value is SteamAuthenticator steamAuthenticator)
try
{
SteamData =
Serializable.GetIndented(steamAuthenticator.SteamData, Serializable.JsonImplType.SystemTextJson);
RecoverCode = steamAuthenticator.RecoveryCode;
DeviceId = steamAuthenticator.DeviceId;
if (authenticatorDto.Value is SteamAuthenticator steamAuthenticator)
{
SteamData =
Serializable.GetIndented(steamAuthenticator.SteamData, Serializable.JsonImplType.SystemTextJson);
RecoverCode = steamAuthenticator.RecoveryCode;
DeviceId = steamAuthenticator.DeviceId;

// var viewModel = new TextBoxWindowViewModel()
// {
// InputType = TextBoxWindowViewModel.TextBoxInputType.ReadOnlyText,
// Value = steamData,
//
// };
//await IWindowManager.Instance.ShowTaskDialogAsync(viewModel, Strings.LocalAuth_ShowAuthInfo);
// var viewModel = new TextBoxWindowViewModel()
// {
// InputType = TextBoxWindowViewModel.TextBoxInputType.ReadOnlyText,
// Value = steamData,
//
// };
//await IWindowManager.Instance.ShowTaskDialogAsync(viewModel, Strings.LocalAuth_ShowAuthInfo);
}
}
catch (Exception ex)
{
ex.LogAndShowT();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,44 @@ public SteamTradePageViewModel(ref IAuthenticatorDTO authenticatorDto)
ConfirmTradeCommand = ReactiveCommand.Create<SteamTradeConfirmationModel>(ConfirmTrade);
CancelTradeCommand = ReactiveCommand.Create<SteamTradeConfirmationModel>(CancelTrade);

if (authenticatorDto.Value is SteamAuthenticator steamAuthenticator)
try
{
_steamAuthenticator = steamAuthenticator;
_steamClient = _steamAuthenticator.GetClient(ResourceService.GetCurrentCultureSteamLanguageName());
UserNameText = _steamAuthenticator.AccountName ?? "";
authenticatorDto.Value = _steamAuthenticator;
_ = Initialize();

this.WhenAnyValue(v => v.Confirmations)
.Subscribe(items => items?
.ToObservableChangeSet()
.AutoRefresh(x => x.IsSelected)
.WhenValueChanged(x => x.IsSelected)
.Subscribe(_ =>
{
bool? b = null;
var count = items.Count(s => s.IsSelected);
if (!items.Any_Nullable() || count == 0)
b = false;
else if (count == items.Count)
b = true;

if (SelectedAll != b)
if (authenticatorDto.Value is SteamAuthenticator steamAuthenticator)
{
_steamAuthenticator = steamAuthenticator;
_steamClient = _steamAuthenticator.GetClient(ResourceService.GetCurrentCultureSteamLanguageName());
UserNameText = _steamAuthenticator.AccountName ?? "";
authenticatorDto.Value = _steamAuthenticator;
_ = Initialize();

this.WhenAnyValue(v => v.Confirmations)
.Subscribe(items => items?
.ToObservableChangeSet()
.AutoRefresh(x => x.IsSelected)
.WhenValueChanged(x => x.IsSelected)
.Subscribe(_ =>
{
SelectedAll = b;
}
}));
bool? b = null;
var count = items.Count(s => s.IsSelected);
if (!items.Any_Nullable() || count == 0)
b = false;
else if (count == items.Count)
b = true;

if (SelectedAll != b)
{
SelectedAll = b;
}
}));
}
else
{
Close?.Invoke();
}
}
else
catch (Exception ex)
{
Close?.Invoke();
ex.LogAndShowT();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ public void ManualRunNext()

private async Task<bool> LoginSteam()
{
var seesion = await Ioc.Get<ISteamSessionService>()
.LoadSession(Path.Combine(Plugin.Instance.CacheDirectory));

if (seesion != null && ulong.TryParse(seesion.SteamId, out var steamid))
{
SteamLoginState.Success = true;
SteamLoginState.SteamId = steamid;
SteamLoginState.AccessToken = seesion.AccessToken;
SteamLoginState.RefreshToken = seesion.RefreshToken;
SteamLoginState.Cookies = seesion.CookieContainer.GetAllCookies();
}

if (!SteamLoginState.Success)
{
var vm = new IdleSteamLoginPageViewModel(ref SteamLoginState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace BD.WTTS.UI.ViewModels;

public sealed partial class IdleCardPageViewModel
{

public ICommand IdleRunStartOrStop { get; }

public ICommand IdleManualRunNext { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace BD.WTTS.UI.ViewModels;
public sealed partial class IdleSteamLoginPageViewModel : WindowViewModel
{
readonly ISteamAccountService Account = Ioc.Get<ISteamAccountService>();
readonly ISteamSessionService SteamSession = Ioc.Get<ISteamSessionService>();

public SteamLoginState SteamLoginState { get; set; }

Expand Down Expand Up @@ -49,7 +50,10 @@ private async void SteamLogin()
{
if (RemenberLogin)
{
var session = SteamSession.RentSession(SteamLoginState.SteamId.ToString());

if (session != null)
await SteamSession.SaveSession(session);
}
Toast.Show(ToastIcon.Success, Strings.Success_.Format(Strings.User_Login));
IsLoading = false;
Expand Down
Loading

0 comments on commit bfd6b82

Please sign in to comment.