Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #24 from Zaxiure/development
Browse files Browse the repository at this point in the history
Fixed crashing when switching tabs. Shouldn't happen anymore.
  • Loading branch information
Zaxiure committed Oct 9, 2022
2 parents 2a04288 + c1ec0ca commit 4c9ade0
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 58 deletions.
8 changes: 0 additions & 8 deletions HuntStats.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ VisualStudioVersion = 17.0.31611.283
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HuntStats", "HuntStats\HuntStats.csproj", "{D4953EB7-30D6-460C-BDAC-E7FE2F0D4345}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "HuntStatsSetup", "HuntStatsSetup\HuntStatsSetup.vdproj", "{A54882C3-48DB-4861-8A24-477D4E99874A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
All|Any CPU = All|Any CPU
Expand Down Expand Up @@ -34,12 +32,6 @@ Global
{D4953EB7-30D6-460C-BDAC-E7FE2F0D4345}.Release|x86.ActiveCfg = Release|Any CPU
{D4953EB7-30D6-460C-BDAC-E7FE2F0D4345}.Release|x86.Build.0 = Release|Any CPU
{D4953EB7-30D6-460C-BDAC-E7FE2F0D4345}.Release|x86.Deploy.0 = Release|Any CPU
{A54882C3-48DB-4861-8A24-477D4E99874A}.All|Any CPU.ActiveCfg = Debug
{A54882C3-48DB-4861-8A24-477D4E99874A}.All|x86.ActiveCfg = Debug
{A54882C3-48DB-4861-8A24-477D4E99874A}.Debug|Any CPU.ActiveCfg = Debug
{A54882C3-48DB-4861-8A24-477D4E99874A}.Debug|x86.ActiveCfg = Debug
{A54882C3-48DB-4861-8A24-477D4E99874A}.Release|Any CPU.ActiveCfg = Release
{A54882C3-48DB-4861-8A24-477D4E99874A}.Release|x86.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion HuntStats/Features/ChartHandlers/KillChartHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ public async Task<List<KillChartInfo>> Handle(KillChartQuery request, Cancellati
};
}
return null;
}).Where(x => x != null).Select(x => x.Result).OrderBy(x => x.DateTime).ToList();
}).Select(x => x.Result).Where(x => x != null).OrderBy(x => x.DateTime).ToList();
}
}
2 changes: 1 addition & 1 deletion HuntStats/Features/XmlFileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ await con.InsertAsync(new TeamTable()
MatchId = matchId
});
}
_appState.MatchAdded();
}


_appState.MatchAdded();
return GeneralStatus.Succes;
}
catch (Exception e)
Expand Down
5 changes: 4 additions & 1 deletion HuntStats/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace HuntStats;
using HuntStats.Models;
using Serilog;

namespace HuntStats;

public partial class MainPage : ContentPage
{
Expand Down
32 changes: 10 additions & 22 deletions HuntStats/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@using HuntStats.Features
@using HuntStats.Features.ChartHandlers
@using HuntStats.Models
@implements IDisposable
@using HuntStats.State
@using MediatR
@inject IFolderPicker _folderPicker
Expand Down Expand Up @@ -152,22 +153,25 @@
}
};

public BackgroundWorker worker { get; set; }
public bool RunBackgroundTask { get; set; } = false;
public string FilePath { get; set; }
public string Path { get; set; } = "";

protected override async Task OnInitializedAsync()
{
await Task.Yield();
AppState.NewMatchAdded += AppStateOnNewMatchAdded;
await GetChartInfo();
}

public async void Dispose()
{
AppState.NewMatchAdded -= AppStateOnNewMatchAdded;
await JS.InvokeAsync<string>("resetChart", _killChart);
await JS.InvokeAsync<string>("resetChart", _mmrChart);
await JS.InvokeAsync<string>("resetChart", _xpChart);
await JS.InvokeAsync<string>("resetChart", _moneyChart);
}

private async void AppStateOnNewMatchAdded()
{
await GetChartInfo(true);
StateHasChanged();
await InvokeAsync(StateHasChanged);
}

Expand Down Expand Up @@ -306,20 +310,4 @@
}
});
}

public async Task ToggleCheck()
{
if (!worker.CancellationPending)
{
if (worker.IsBusy)
{
worker.CancelAsync();
}
else
{
worker.RunWorkerAsync();
}
}
StateHasChanged();
}
}
4 changes: 2 additions & 2 deletions HuntStats/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
}
}

private void AppStateOnPathChangedEvent(string obj)
private async void AppStateOnPathChangedEvent(string obj)
{
Path = obj;
if (worker != null)
Expand All @@ -138,7 +138,7 @@
if (!worker.CancellationPending && worker.IsBusy) worker.CancelAsync();
}
}
StateHasChanged();
await InvokeAsync(StateHasChanged);
}

private void ConstructWorker()
Expand Down
32 changes: 9 additions & 23 deletions HuntStats/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,44 +34,30 @@

window.resetChart = (el) => {
var chartToRefresh = charts.filter(x => x.canvas == el)[0];
chartToRefresh.destroy();
charts.splice(charts.indexOf(chartToRefresh), 1);
if(chartToRefresh !== undefined) {
chartToRefresh.destroy();
charts.splice(charts.indexOf(chartToRefresh), 1);
}
}

window.resetCharts = () => {
charts.forEach(x => {
x.destroy();
if(x !== undefined) {
if(x.destroy !== undefined) {
x.destroy();
}
}
})
charts = [];
}

window.createChart = (chartElement, data) => {
console.log(data);
console.log(chartElement);
// var labels = Utils.months({count: 7});
charts = [...charts, new Chart(chartElement, {
type: "line",
data: data,
options: {
responsive:true,
maintainAspectRatio: false,
// plugins: {
// annotation: {
// annotations: {
// line1: {
// type: 'line',
// yMin: 2000,
// yMax: 2000,
// label: {
// display: true,
// content: 'Test'
// },
// borderColor: 'rgb(255, 99, 132)',
// borderWidth: 2,
// }
// }
// }
// },
scales: {
y: {
suggestedMax: 10,
Expand Down

0 comments on commit 4c9ade0

Please sign in to comment.