From 8444e4dca01a4d3831655c909ef1647c8a6e68b0 Mon Sep 17 00:00:00 2001 From: Nicola <61830443+nicola02nb@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:16:15 +0100 Subject: [PATCH] Fixed mime types button not updating after install/uninstall (#241) --- src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs | 10 ++++++++-- src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs index 53263847b..f1587a0ff 100644 --- a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs @@ -102,6 +102,7 @@ namespace Ryujinx.Ava.UI.ViewModels private float _volumeBeforeMute; private string _backendText; + private bool _areMimeTypesRegistered = FileAssociationHelper.AreMimeTypesRegistered; private bool _canUpdate = true; private Cursor _cursor; private string _title; @@ -804,10 +805,15 @@ namespace Ryujinx.Ava.UI.ViewModels { get => FileAssociationHelper.IsTypeAssociationSupported; } - + public bool AreMimeTypesRegistered { - get => FileAssociationHelper.AreMimeTypesRegistered; + get => _areMimeTypesRegistered; + set { + _areMimeTypesRegistered = value; + + OnPropertyChanged(); + } } public ObservableCollectionExtended Applications diff --git a/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs b/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs index 144ab408f..41b27e9c1 100644 --- a/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs +++ b/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs @@ -165,7 +165,8 @@ namespace Ryujinx.Ava.UI.Views.Main private async void InstallFileTypes_Click(object sender, RoutedEventArgs e) { - if (FileAssociationHelper.Install()) + ViewModel.AreMimeTypesRegistered = FileAssociationHelper.Install(); + if (ViewModel.AreMimeTypesRegistered) await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogInstallFileTypesSuccessMessage], string.Empty, LocaleManager.Instance[LocaleKeys.InputDialogOk], string.Empty, string.Empty); else await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogInstallFileTypesErrorMessage]); @@ -173,7 +174,8 @@ namespace Ryujinx.Ava.UI.Views.Main private async void UninstallFileTypes_Click(object sender, RoutedEventArgs e) { - if (FileAssociationHelper.Uninstall()) + ViewModel.AreMimeTypesRegistered = !FileAssociationHelper.Uninstall(); + if (!ViewModel.AreMimeTypesRegistered) await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogUninstallFileTypesSuccessMessage], string.Empty, LocaleManager.Instance[LocaleKeys.InputDialogOk], string.Empty, string.Empty); else await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogUninstallFileTypesErrorMessage]);