From 937ce812054b02165a259e7a3a6a2b8ea3b086e4 Mon Sep 17 00:00:00 2001 From: JanuarySnow Date: Wed, 23 Aug 2023 15:24:57 +0100 Subject: [PATCH 1/3] hide remaining time when paused --- .../Downloads/InProgressCommonViewModel.cs | 2 +- .../RightContent/Downloads/InProgressView.axaml.cs | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/NexusMods.App.UI/RightContent/Downloads/InProgressCommonViewModel.cs b/src/NexusMods.App.UI/RightContent/Downloads/InProgressCommonViewModel.cs index 712b8aee18..e3e99105cc 100644 --- a/src/NexusMods.App.UI/RightContent/Downloads/InProgressCommonViewModel.cs +++ b/src/NexusMods.App.UI/RightContent/Downloads/InProgressCommonViewModel.cs @@ -176,7 +176,7 @@ protected virtual void UpdateWindowInfo() // Calculate Remaining Time. var throughput = Tasks.Sum(x => x.Throughput); var remainingBytes = totalSizeBytes - totalDownloadedBytes; - SecondsRemaining = (int)(remainingBytes / Math.Max(throughput, 1)); + SecondsRemaining = throughput < 1.0 ? 0 : (int)(remainingBytes / Math.Max(throughput, 1)); } private void UpdateWindowInfoInternal(object? sender, object? state) => UpdateWindowInfo(); diff --git a/src/NexusMods.App.UI/RightContent/Downloads/InProgressView.axaml.cs b/src/NexusMods.App.UI/RightContent/Downloads/InProgressView.axaml.cs index 03d510bbef..402d5baac2 100644 --- a/src/NexusMods.App.UI/RightContent/Downloads/InProgressView.axaml.cs +++ b/src/NexusMods.App.UI/RightContent/Downloads/InProgressView.axaml.cs @@ -1,4 +1,4 @@ -using System.Reactive.Disposables; +using System.Reactive.Disposables; using System.Reactive.Linq; using Avalonia.ReactiveUI; using DynamicData.Binding; @@ -78,7 +78,16 @@ public InProgressView() .Subscribe(_ => { var vm = ViewModel!; - BoldMinutesRemainingTextBlock.Text = StringFormatters.ToTimeRemainingShort(vm.SecondsRemaining); + if (vm.SecondsRemaining == 0) + { + BoldMinutesRemainingTextBlock.Text = ""; + MinutesRemainingTextBlock.Text = ""; + } + else + { + BoldMinutesRemainingTextBlock.Text = StringFormatters.ToTimeRemainingShort(vm.SecondsRemaining); + MinutesRemainingTextBlock.Text = "Remaining"; + } }) .DisposeWith(d); From c792cb54db9d4ea8098017f4d90289640d9a3a0f Mon Sep 17 00:00:00 2001 From: JanuarySnow Date: Wed, 23 Aug 2023 17:56:26 +0100 Subject: [PATCH 2/3] update tests code to account for empty string in time remaining text when no downloads occuring --- .../RightContent/Downloads/InProgressViewModelTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/NexusMods.UI.Tests/RightContent/Downloads/InProgressViewModelTests.cs b/tests/NexusMods.UI.Tests/RightContent/Downloads/InProgressViewModelTests.cs index abc47dd2df..c698141753 100644 --- a/tests/NexusMods.UI.Tests/RightContent/Downloads/InProgressViewModelTests.cs +++ b/tests/NexusMods.UI.Tests/RightContent/Downloads/InProgressViewModelTests.cs @@ -203,7 +203,8 @@ await OnUi(() => // Check the total completion is correct with 0 elements. var originalTimeRemaining = StringFormatters.ToTimeRemainingShort(ViewModel.SecondsRemaining); - View.BoldMinutesRemainingTextBlock.Text.Should().Be(originalTimeRemaining); + // Time remaining text is empty when no downloads occuring + View.BoldMinutesRemainingTextBlock.Text.Should().Be(""); // Check the total completion is correct with 1 element. ViewModel.AddDownload(new DownloadTaskDesignViewModel() From f95ee7e97bf7426f7f9797decd87236e1c28e3f4 Mon Sep 17 00:00:00 2001 From: JanuarySnow Date: Wed, 23 Aug 2023 18:03:49 +0100 Subject: [PATCH 3/3] add handling in tests for specificty on the timeremaining being zero --- .../Downloads/InProgressViewModelTests.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/NexusMods.UI.Tests/RightContent/Downloads/InProgressViewModelTests.cs b/tests/NexusMods.UI.Tests/RightContent/Downloads/InProgressViewModelTests.cs index c698141753..db8ceb905c 100644 --- a/tests/NexusMods.UI.Tests/RightContent/Downloads/InProgressViewModelTests.cs +++ b/tests/NexusMods.UI.Tests/RightContent/Downloads/InProgressViewModelTests.cs @@ -200,11 +200,18 @@ await OnUi(() => { ViewModel.ClearDownloads(); ViewModel.IsRunning.Should().BeFalse(); - + // Check the total completion is correct with 0 elements. var originalTimeRemaining = StringFormatters.ToTimeRemainingShort(ViewModel.SecondsRemaining); - // Time remaining text is empty when no downloads occuring - View.BoldMinutesRemainingTextBlock.Text.Should().Be(""); + // If 0 seconds remaining, then no download is occuring, and the text block is empty string + if (ViewModel.SecondsRemaining == 0) + { + View.BoldMinutesRemainingTextBlock.Text.Should().Be(""); + } + else + { + View.BoldMinutesRemainingTextBlock.Text.Should().Be(originalTimeRemaining); + } // Check the total completion is correct with 1 element. ViewModel.AddDownload(new DownloadTaskDesignViewModel()