From 004f11cb6e465dceb6a5c5ea8d8deffb642d383a Mon Sep 17 00:00:00 2001 From: sahin-a Date: Sun, 16 Apr 2023 00:03:54 +0200 Subject: [PATCH] avatars are now bigger and currently logged in steam account now gets a green border --- .../Mappers/AccountMapper.cs | 17 ++++++------- .../Models/Account.cs | 1 + .../SteamAccountSwitcherStyles.xaml | 12 ++++++++++ .../ViewModels/AccountSwitcherViewModel.cs | 2 -- .../Views/AccountSwitcherView.axaml | 24 ++++++++++++------- .../Steam/Model/Account.cs | 3 ++- .../UseCase/GetAccountsWithDetailsUseCase.cs | 15 +++++++----- 7 files changed, 49 insertions(+), 25 deletions(-) diff --git a/SteamAccountManager.AvaloniaUI/Mappers/AccountMapper.cs b/SteamAccountManager.AvaloniaUI/Mappers/AccountMapper.cs index e425f22..df1318e 100644 --- a/SteamAccountManager.AvaloniaUI/Mappers/AccountMapper.cs +++ b/SteamAccountManager.AvaloniaUI/Mappers/AccountMapper.cs @@ -1,11 +1,10 @@ -using SteamAccountManager.AvaloniaUI.Common; +using System; +using System.Text; +using System.Threading.Tasks; +using SteamAccountManager.AvaloniaUI.Common; using SteamAccountManager.AvaloniaUI.Common.Utils; using SteamAccountManager.AvaloniaUI.Models; using SteamAccountManager.AvaloniaUI.Services; -using System; -using System.Text; -using System.Threading.Tasks; -using Account = SteamAccountManager.AvaloniaUI.Models.Account; namespace SteamAccountManager.AvaloniaUI.Mappers { @@ -34,6 +33,7 @@ private string GetTimePassedFormatted(long minutesPassed) stringBuilder.Append($"{minutesPassed} minutes"); break; } + stringBuilder.Append(" ago"); return stringBuilder.ToString(); @@ -46,7 +46,7 @@ public async Task FromSteamAccount(Domain.Steam.Model.Account steamAcco var avatar = await _avatarService.GetAvatarAsync(steamAccount.Id, steamAccount.AvatarUrl); var rank = new Rank { - Level = steamAccount.Level + Level = steamAccount.Level, }; return new Account @@ -60,8 +60,9 @@ public async Task FromSteamAccount(Domain.Steam.Model.Account steamAcco IsVacBanned = steamAccount.IsVacBanned, IsCommunityBanned = steamAccount.IsCommunityBanned, LastLogin = timePassedSinceLastLogin, - Rank = rank + Rank = rank, + IsLoggedIn = steamAccount.IsLoggedIn, }; } } -} +} \ No newline at end of file diff --git a/SteamAccountManager.AvaloniaUI/Models/Account.cs b/SteamAccountManager.AvaloniaUI/Models/Account.cs index 58d1995..9bd968c 100644 --- a/SteamAccountManager.AvaloniaUI/Models/Account.cs +++ b/SteamAccountManager.AvaloniaUI/Models/Account.cs @@ -14,6 +14,7 @@ public class Account public bool IsVacBanned { get; set; } public bool IsCommunityBanned { get; set; } public string LastLogin { get; set; } = string.Empty; + public bool IsLoggedIn { get; set; } public Rank Rank { get; set; } = new() { diff --git a/SteamAccountManager.AvaloniaUI/SteamAccountSwitcherStyles.xaml b/SteamAccountManager.AvaloniaUI/SteamAccountSwitcherStyles.xaml index 3bc950f..fb2c3db 100644 --- a/SteamAccountManager.AvaloniaUI/SteamAccountSwitcherStyles.xaml +++ b/SteamAccountManager.AvaloniaUI/SteamAccountSwitcherStyles.xaml @@ -48,4 +48,16 @@ + + + + \ No newline at end of file diff --git a/SteamAccountManager.AvaloniaUI/ViewModels/AccountSwitcherViewModel.cs b/SteamAccountManager.AvaloniaUI/ViewModels/AccountSwitcherViewModel.cs index f9b5cf3..331898a 100644 --- a/SteamAccountManager.AvaloniaUI/ViewModels/AccountSwitcherViewModel.cs +++ b/SteamAccountManager.AvaloniaUI/ViewModels/AccountSwitcherViewModel.cs @@ -34,7 +34,6 @@ public class AccountSwitcherViewModel : RoutableViewModel public ICommand RefreshAccountsCommand { get; } public ICommand ShowInfoCommand { get; } public ICommand AddAccountCommand { get; } - public Account? SelectedAccount { get; set; } public VisibilityConfig Config { get; private set; } = new(); private bool _isLoading; @@ -161,7 +160,6 @@ private async void SendNotification(Account account) public async void OnAccountSelected(Account selectedAccount) { await _switchAccountUseCase.Execute(selectedAccount.Name); - SelectedAccount = selectedAccount; SendNotification(selectedAccount); } diff --git a/SteamAccountManager.AvaloniaUI/Views/AccountSwitcherView.axaml b/SteamAccountManager.AvaloniaUI/Views/AccountSwitcherView.axaml index 9c3a371..127ca54 100644 --- a/SteamAccountManager.AvaloniaUI/Views/AccountSwitcherView.axaml +++ b/SteamAccountManager.AvaloniaUI/Views/AccountSwitcherView.axaml @@ -22,6 +22,7 @@ + @@ -62,14 +63,22 @@ IsVisible="{Binding Path=DataContext.Config.ShowAvatar, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" Margin="0,0,12,0"> - - - - + + + + + + + + + + + + + + @@ -79,8 +88,7 @@ - + diff --git a/SteamAccountManager.Domain/Steam/Model/Account.cs b/SteamAccountManager.Domain/Steam/Model/Account.cs index 8220862..fdabcfc 100644 --- a/SteamAccountManager.Domain/Steam/Model/Account.cs +++ b/SteamAccountManager.Domain/Steam/Model/Account.cs @@ -12,5 +12,6 @@ public class Account public bool IsLoginValid { get; set; } public DateTime LastLogin { get; set; } public int Level { get; set; } + public bool IsLoggedIn { get; set; } } -} +} \ No newline at end of file diff --git a/SteamAccountManager.Domain/Steam/UseCase/GetAccountsWithDetailsUseCase.cs b/SteamAccountManager.Domain/Steam/UseCase/GetAccountsWithDetailsUseCase.cs index cc17790..02e211e 100644 --- a/SteamAccountManager.Domain/Steam/UseCase/GetAccountsWithDetailsUseCase.cs +++ b/SteamAccountManager.Domain/Steam/UseCase/GetAccountsWithDetailsUseCase.cs @@ -11,7 +11,8 @@ public class GetAccountsWithDetailsUseCase : IGetAccountsWithDetailsUseCase private readonly ISteamProfileService _steamProfileService; private readonly ILogger _logger; - public GetAccountsWithDetailsUseCase(ISteamRepository steamRepository, ISteamProfileService steamProfileService, ILogger logger) + public GetAccountsWithDetailsUseCase(ISteamRepository steamRepository, ISteamProfileService steamProfileService, + ILogger logger) { _steamRepository = steamRepository; _steamProfileService = steamProfileService; @@ -22,6 +23,7 @@ public async Task> Execute() { try { + var currentlySetAutoLoginUserId = (await _steamRepository.GetCurrentAutoLoginUser()).SteamId; var steamLoginUsers = await _steamRepository.GetSteamLoginHistoryUsers(); var steamIds = steamLoginUsers.Select(user => user.SteamId); var steamProfiles = await _steamProfileService.GetProfileDetails(steamIds.ToArray()); @@ -30,14 +32,14 @@ public async Task> Execute() { var steamProfile = steamProfiles.FirstOrDefault( profile => profile.Id == steamLoginUser.SteamId, - new Profile() + new Profile { Username = steamLoginUser.Username, - Level = -1 + Level = -1, } ); - return new Account() + return new Account { Id = steamLoginUser.SteamId, Name = steamLoginUser.AccountName, @@ -48,7 +50,8 @@ public async Task> Execute() IsCommunityBanned = steamProfile.IsCommunityBanned, LastLogin = steamLoginUser.LastLogin, IsLoginValid = steamLoginUser.IsLoginTokenValid, - Level = steamProfile.Level + Level = steamProfile.Level, + IsLoggedIn = steamLoginUser.SteamId == currentlySetAutoLoginUserId, }; }); @@ -62,4 +65,4 @@ public async Task> Execute() return new List(); } } -} +} \ No newline at end of file