Skip to content

Commit

Permalink
Merge pull request #286 from stevejackson80/WIP/Add-Logout-Button
Browse files Browse the repository at this point in the history
Added a logout button so that a "saved profile" can be forgotten.
  • Loading branch information
artehe authored May 24, 2024
2 parents 4b25190 + 78f14df commit 99886d5
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions SIT.Manager/Localization/en-US.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@
<!-- CharacterSummaryView -->
<system:String x:Key="CharacterSummaryViewPlayButtonText">Play</system:String>
<system:String x:Key="CharacterSummaryViewLoginButtonText">Login</system:String>
<system:String x:Key="CharacterSummaryViewLogoutButtonText">Logout</system:String>

<!-- CreateServerDialogView -->
<system:String x:Key="CreateServerDialogViewAddTitle">Add Server</system:String>
Expand Down
1 change: 1 addition & 0 deletions SIT.Manager/Localization/ru-RU.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@
<!-- CharacterSummaryView -->
<system:String x:Key="CharacterSummaryViewPlayButtonText">Играть</system:String>
<system:String x:Key="CharacterSummaryViewLoginButtonText">Войти</system:String>
<system:String x:Key="CharacterSummaryViewLogoutButtonText">Выход</system:String>

<!-- CreateServerDialogView -->
<system:String x:Key="CreateServerDialogViewAddTitle">Добавить сервер</system:String>
Expand Down
1 change: 1 addition & 0 deletions SIT.Manager/Localization/uk-UA.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@
<!-- CharacterSummaryView -->
<system:String x:Key="CharacterSummaryViewPlayButtonText">Грати</system:String>
<system:String x:Key="CharacterSummaryViewLoginButtonText">Ввійти</system:String>
<system:String x:Key="CharacterSummaryViewLogoutButtonText">Вихід</system:String>

<!-- CreateServerDialogView -->
<system:String x:Key="CreateServerDialogViewAddTitle">Додати сервер</system:String>
Expand Down
1 change: 1 addition & 0 deletions SIT.Manager/Localization/zh-CN.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@
<!-- CharacterSummaryView -->
<system:String x:Key="CharacterSummaryViewPlayButtonText">玩</system:String>
<system:String x:Key="CharacterSummaryViewLoginButtonText">登录</system:String>
<system:String x:Key="CharacterSummaryViewLogoutButtonText">注销</system:String>

<!-- CreateServerDialogView -->
<system:String x:Key="CreateServerDialogViewAddTitle">添加服务器</system:String>
Expand Down
1 change: 1 addition & 0 deletions SIT.Manager/Localization/zh-HK.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@
<!-- CharacterSummaryView -->
<system:String x:Key="CharacterSummaryViewPlayButtonText">玩</system:String>
<system:String x:Key="CharacterSummaryViewLoginButtonText">登錄</system:String>
<system:String x:Key="CharacterSummaryViewLogoutButtonText">注销</system:String>

<!-- CreateServerDialogView -->
<system:String x:Key="CreateServerDialogViewAddTitle">添加伺服器</system:String>
Expand Down
1 change: 1 addition & 0 deletions SIT.Manager/Localization/zh-TW.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@
<!-- CharacterSummaryView -->
<system:String x:Key="CharacterSummaryViewPlayButtonText">玩</system:String>
<system:String x:Key="CharacterSummaryViewLoginButtonText">登入</system:String>
<system:String x:Key="CharacterSummaryViewLogoutButtonText">注销</system:String>

<!-- CreateServerDialogView -->
<system:String x:Key="CreateServerDialogViewAddTitle">添加伺服器</system:String>
Expand Down
20 changes: 15 additions & 5 deletions SIT.Manager/ViewModels/Play/CharacterSummaryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using SIT.Manager.Services.Caching;
using SIT.Manager.Views.Play;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

Expand Down Expand Up @@ -43,6 +45,8 @@ public partial class CharacterSummaryViewModel : ObservableRecipient

public IAsyncRelayCommand PlayCommand { get; }

public IAsyncRelayCommand LogoutCommand { get; }

public CharacterSummaryViewModel(AkiServer server,
AkiMiniProfile profile,
ILocalizationService localizationService,
Expand Down Expand Up @@ -86,6 +90,7 @@ public CharacterSummaryViewModel(AkiServer server,
Task.Run(SetSideImage);

PlayCommand = new AsyncRelayCommand(Play);
LogoutCommand = new AsyncRelayCommand(Logout);
}

private async Task SetSideImage()
Expand Down Expand Up @@ -143,11 +148,6 @@ private async Task Play()
if (success && rememberLogin)
{
_connectedServer.Characters.Add(character);
int index = _configService.Config.BookmarkedServers.FindIndex(x => x.Address == _connectedServer.Address);
if (index != -1 && !_configService.Config.BookmarkedServers[index].Characters.Any(x => x.Username == character.Username))
{
_configService.Config.BookmarkedServers[index].Characters.Add(character);
}
_configService.UpdateConfig(_configService.Config);
RequireLogin = false;
}
Expand All @@ -164,4 +164,14 @@ private async Task Play()
await errorDialog.ShowAsync();
}
}

private async Task Logout()

Check warning on line 168 in SIT.Manager/ViewModels/Play/CharacterSummaryViewModel.cs

View workflow job for this annotation

GitHub Actions / build (win-x64)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 168 in SIT.Manager/ViewModels/Play/CharacterSummaryViewModel.cs

View workflow job for this annotation

GitHub Actions / build (win-x64)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 168 in SIT.Manager/ViewModels/Play/CharacterSummaryViewModel.cs

View workflow job for this annotation

GitHub Actions / build (linux-x64)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 168 in SIT.Manager/ViewModels/Play/CharacterSummaryViewModel.cs

View workflow job for this annotation

GitHub Actions / build (linux-x64)

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
if (character != null)
{
_connectedServer.Characters.Remove(character);
_configService.UpdateConfig(_configService.Config);
RequireLogin = true;
}
}
}
11 changes: 10 additions & 1 deletion SIT.Manager/Views/Play/CharacterSummaryView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
x:Class="SIT.Manager.Views.Play.CharacterSummaryView"
x:DataType="vm:CharacterSummaryViewModel">
<controls:Card Margin="8">
<Grid ColumnDefinitions="Auto, *, Auto">
<Grid ColumnDefinitions="Auto, *, Auto, Auto">
<StackPanel Grid.Column="0">
<Image Grid.Column="0"
VerticalAlignment="Center"
Expand Down Expand Up @@ -61,6 +61,15 @@
Text="{DynamicResource CharacterSummaryViewLoginButtonText}"/>
</Panel>
</Button>

<Button Grid.Column="3"
Margin="14,0"
Command="{Binding LogoutCommand}"
IsVisible="{Binding !RequireLogin}">
<Panel>
<TextBlock Text="{DynamicResource CharacterSummaryViewLogoutButtonText}"/>
</Panel>
</Button>
</Grid>
</controls:Card>
</UserControl>

0 comments on commit 99886d5

Please sign in to comment.