diff --git a/HuntStats.sln b/HuntStats.sln index b79512e..54d05ed 100644 --- a/HuntStats.sln +++ b/HuntStats.sln @@ -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 @@ -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 diff --git a/HuntStats/Features/ChartHandlers/KillChartHandler.cs b/HuntStats/Features/ChartHandlers/KillChartHandler.cs index 5e55e3a..f75b533 100644 --- a/HuntStats/Features/ChartHandlers/KillChartHandler.cs +++ b/HuntStats/Features/ChartHandlers/KillChartHandler.cs @@ -62,6 +62,6 @@ public async Task> 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(); } } diff --git a/HuntStats/Features/XmlFileHandler.cs b/HuntStats/Features/XmlFileHandler.cs index 2976c31..6b763e6 100644 --- a/HuntStats/Features/XmlFileHandler.cs +++ b/HuntStats/Features/XmlFileHandler.cs @@ -319,10 +319,10 @@ await con.InsertAsync(new TeamTable() MatchId = matchId }); } + _appState.MatchAdded(); } - _appState.MatchAdded(); return GeneralStatus.Succes; } catch (Exception e) diff --git a/HuntStats/MainPage.xaml.cs b/HuntStats/MainPage.xaml.cs index e5fc6f8..10baba0 100644 --- a/HuntStats/MainPage.xaml.cs +++ b/HuntStats/MainPage.xaml.cs @@ -1,4 +1,7 @@ -namespace HuntStats; +using HuntStats.Models; +using Serilog; + +namespace HuntStats; public partial class MainPage : ContentPage { diff --git a/HuntStats/Pages/Index.razor b/HuntStats/Pages/Index.razor index 0b902ae..e94b2e2 100644 --- a/HuntStats/Pages/Index.razor +++ b/HuntStats/Pages/Index.razor @@ -7,6 +7,7 @@ @using HuntStats.Features @using HuntStats.Features.ChartHandlers @using HuntStats.Models +@implements IDisposable @using HuntStats.State @using MediatR @inject IFolderPicker _folderPicker @@ -152,11 +153,6 @@ } }; - 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(); @@ -164,10 +160,18 @@ await GetChartInfo(); } + public async void Dispose() + { + AppState.NewMatchAdded -= AppStateOnNewMatchAdded; + await JS.InvokeAsync("resetChart", _killChart); + await JS.InvokeAsync("resetChart", _mmrChart); + await JS.InvokeAsync("resetChart", _xpChart); + await JS.InvokeAsync("resetChart", _moneyChart); + } + private async void AppStateOnNewMatchAdded() { await GetChartInfo(true); - StateHasChanged(); await InvokeAsync(StateHasChanged); } @@ -306,20 +310,4 @@ } }); } - - public async Task ToggleCheck() - { - if (!worker.CancellationPending) - { - if (worker.IsBusy) - { - worker.CancelAsync(); - } - else - { - worker.RunWorkerAsync(); - } - } - StateHasChanged(); - } } \ No newline at end of file diff --git a/HuntStats/Shared/MainLayout.razor b/HuntStats/Shared/MainLayout.razor index 8dc563e..f40bfef 100644 --- a/HuntStats/Shared/MainLayout.razor +++ b/HuntStats/Shared/MainLayout.razor @@ -128,7 +128,7 @@ } } - private void AppStateOnPathChangedEvent(string obj) + private async void AppStateOnPathChangedEvent(string obj) { Path = obj; if (worker != null) @@ -138,7 +138,7 @@ if (!worker.CancellationPending && worker.IsBusy) worker.CancelAsync(); } } - StateHasChanged(); + await InvokeAsync(StateHasChanged); } private void ConstructWorker() diff --git a/HuntStats/wwwroot/index.html b/HuntStats/wwwroot/index.html index 98c48e6..f2badd3 100644 --- a/HuntStats/wwwroot/index.html +++ b/HuntStats/wwwroot/index.html @@ -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,