From 5b563d4f00576539be08398482a88d7cb3232c29 Mon Sep 17 00:00:00 2001 From: Oleksii Holub <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 18 Feb 2022 23:54:59 +0200 Subject: [PATCH] Cleanup some code --- .../ViewModels/RootViewModel.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs b/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs index b3a5709..7afaa00 100644 --- a/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs @@ -30,13 +30,13 @@ public class RootViewModel : Screen private DiscordClient? _discord; - public SnackbarMessageQueue Notifications { get; } = new(TimeSpan.FromSeconds(5)); + public bool IsBusy { get; private set; } public ProgressContainer Progress { get; } = new(); - public bool IsBusy { get; private set; } + public bool IsProgressIndeterminate => IsBusy && Progress.Current.Fraction is <= 0 or >= 1; - public bool IsProgressIndeterminate { get; private set; } + public SnackbarMessageQueue Notifications { get; } = new(TimeSpan.FromSeconds(5)); public string? Token { get; set; } @@ -63,17 +63,12 @@ public class RootViewModel : Screen _settingsService = settingsService; _updateService = updateService; - DisplayName = $"{App.Name} v{App.VersionString}"; - _progressMuxer = Progress.CreateMuxer().WithAutoReset(); - this.Bind(o => o.IsBusy, (_, _) => - IsProgressIndeterminate = IsBusy && Progress.Current.Fraction is <= 0 or >= 1 - ); + DisplayName = $"{App.Name} v{App.VersionString}"; - Progress.Bind(o => o.Current, (_, _) => - IsProgressIndeterminate = IsBusy && Progress.Current.Fraction is <= 0 or >= 1 - ); + this.Bind(o => o.IsBusy, (_, _) => NotifyOfPropertyChange(() => IsProgressIndeterminate)); + Progress.Bind(o => o.Current, (_, _) => NotifyOfPropertyChange(() => IsProgressIndeterminate)); } private async ValueTask CheckForUpdatesAsync()