Skip to content

Commit

Permalink
Merge pull request #466 from dlamkins/feat/gw2sharp-1.3.0
Browse files Browse the repository at this point in the history
Gw2Sharp 1.3.0
  • Loading branch information
dlamkins authored Sep 23, 2021
2 parents 56b09ba + 4f2b6c4 commit cfbdea1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Blish HUD/Blish HUD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Gapotchenko.FX.Diagnostics.Process" Version="2021.1.5" />
<PackageReference Include="Gw2Sharp" Version="[1.0.0]" />
<PackageReference Include="Gw2Sharp" Version="1.3.0" />
<PackageReference Include="Humanizer.Core.de" Version="2.6.2" PrivateAssets="all" />
<PackageReference Include="Humanizer.Core.es" Version="2.6.2" PrivateAssets="all" />
<PackageReference Include="Humanizer.Core.fr" Version="2.6.2" PrivateAssets="all" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class ApiTokenPresenter : Presenter<ApiTokenView, string> {

public ApiTokenPresenter(ApiTokenView view, string apiKey) : base(view, apiKey) {
_loadCancel = new CancellationTokenSource();

this.View.DeleteClicked += TokenDeleteClicked;
}

protected override async Task<bool> Load(IProgress<string> progress) {
Expand Down Expand Up @@ -54,6 +56,12 @@ protected override async Task<bool> Load(IProgress<string> progress) {
return true;
}

private void TokenDeleteClicked(object sender, EventArgs e) {
GameService.Gw2WebApi.UnregisterKey(this.Model);

this.View.RemoveTokenView();
}

private bool UpdateFromRequestTaskResult<T>(Task<T> infoTask, ref T field) {
if (infoTask.IsCanceled) return false;

Expand Down Expand Up @@ -88,6 +96,8 @@ protected override void UpdateView() {
protected override void Unload() {
_loadCancel.Cancel();

this.View.DeleteClicked -= TokenDeleteClicked;

base.Unload();
}

Expand Down
13 changes: 9 additions & 4 deletions Blish HUD/GameServices/Gw2WebApi/UI/Views/ApiTokenView.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Blish_HUD.Controls;
using Blish_HUD.Graphics.UI;
using Blish_HUD.Input;
Expand All @@ -19,6 +20,8 @@ public class ApiTokenView : View {
{"23", ("Spain", GameService.Content.GetTexture(@"common/784344"))}
};

public event EventHandler<EventArgs> DeleteClicked;

private Label _accountNameLbl;
private Label _tokenKeyLbl;
private Label _tokenNameLbl;
Expand Down Expand Up @@ -184,11 +187,13 @@ protected override void Build(Container buildPanel) {
_deleteBttn.Click += DeleteRegisteredToken;
}

private void DeleteRegisteredToken(object sender, MouseEventArgs e) {
GameService.Gw2WebApi.UnregisterKey(_tokenInfo.Id);

public void RemoveTokenView() {
this.ViewTarget.Dispose();
}

private void DeleteRegisteredToken(object sender, MouseEventArgs e) {
this.DeleteClicked?.Invoke(this, EventArgs.Empty);
}

}
}
2 changes: 1 addition & 1 deletion Blish HUD/GameServices/Gw2WebApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ internal string[] GetKeys() {

private void UpdateCharacterList(SettingEntry<string> definedKey) {
GetCharacters(GetConnection(definedKey.Value)).ContinueWith((charactersResponse) => {
if (charactersResponse.Result != null) {
if (charactersResponse.Exception == null && charactersResponse.Result != null) {
foreach (string characterId in charactersResponse.Result) {
_characterRepository.AddOrUpdate(characterId, definedKey.Value, (k, o) => definedKey.Value);
}
Expand Down

0 comments on commit cfbdea1

Please sign in to comment.