Skip to content

Commit

Permalink
Bug fix: The library does not load automatically on first login
Browse files Browse the repository at this point in the history
  • Loading branch information
Yelo420 committed Jan 8, 2024
1 parent 194f8de commit 20c621c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Recommended Gamevault Server Version: `v10.1.0`
- You can now also open the user settings from the settings tab
- The mouse wheel now scrolls horizontally in the installed game scrollbar when visible
- A message is now displayed when an admin tries to change their role
- Bug fix: The library does not load automatically on first login

## 1.8.1
Recommended Gamevault Server Version: `v10.0.2`
Expand Down
2 changes: 1 addition & 1 deletion gamevault/UserControls/LibraryUserControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
xmlns:conv="clr-namespace:gamevault.Converter"
xmlns:local="clr-namespace:gamevault.UserControls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" Loaded="Library_Loaded">
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<conv:GameSizeConverter x:Key="sizeConv"/>
<conv:LibraryPermissionRoleToVisibilityConverter x:Key="libCardsPermVisConv"/>
Expand Down
11 changes: 3 additions & 8 deletions gamevault/UserControls/LibraryUserControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,16 @@ public partial class LibraryUserControl : UserControl
private LibraryViewModel ViewModel;
private InputTimer inputTimer { get; set; }

private bool scrollBlocked = false;
private bool loaded = false;
private bool scrollBlocked = false;
public LibraryUserControl()
{
InitializeComponent();
ViewModel = new LibraryViewModel();
this.DataContext = ViewModel;
InitTimer();
}
private async void Library_Loaded(object sender, RoutedEventArgs e)
public async Task LoadLibrary()
{
if (loaded)
return;

loaded = true;
if (Preferences.Get(AppConfigKey.LibStartup, AppFilePath.UserFile) == "1")
{
await Search();
Expand Down Expand Up @@ -275,7 +270,7 @@ private async void RandomGame_Click(object sender, MouseButtonEventArgs e)
{
string randomGame = WebHelper.GetRequest($"{SettingsViewModel.Instance.ServerUrl}/api/games/random");
return JsonSerializer.Deserialize<Game>(randomGame);
}
}
catch (Exception ex)
{
MainWindowViewModel.Instance.AppBarText = WebExceptionHelper.TryGetServerMessage(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private async Task Login()
LoginState state = await LoginManager.Instance.ManualLogin(SettingsViewModel.Instance.UserName, uiPwBox.Password);
if (LoginState.Success == state)
{
await MainWindowViewModel.Instance.Library.LoadLibrary();//Load library, because otherwise it would be empty for new users at the first login
MainWindowViewModel.Instance.AppBarText = $"Successfully logged in as '{SettingsViewModel.Instance.UserName}'";
}
else if (LoginState.Unauthorized == state)
Expand Down
2 changes: 1 addition & 1 deletion gamevault/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private async void MetroWindow_Loaded(object sender, System.Windows.RoutedEventA
LoginState state = LoginManager.Instance.GetState();
if (LoginState.Success == state)
{

await MainWindowViewModel.Instance.Library.LoadLibrary();
}
else if (LoginState.Unauthorized == state || LoginState.Forbidden == state)
{
Expand Down

0 comments on commit 20c621c

Please sign in to comment.