updating: do not update update_check date when we couldn't do it (#9038)

* updating: do not update update_check date when we couldn't do it

- improve general settings page "Last Checked" feature
This commit is contained in:
Andrey Nekrasov
2021-01-12 18:34:02 +03:00
committed by GitHub
parent 7bcf4b7894
commit 1364f78b30
9 changed files with 110 additions and 56 deletions

View File

@@ -237,6 +237,14 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
}
}
public static bool AutoUpdatesEnabled
{
get
{
return Helper.GetProductVersion() != "v0.0.1";
}
}
[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "This may throw if the XAML page is not initialized in tests (https://github.com/microsoft/PowerToys/pull/2676)")]
public bool IsDarkThemeRadioButtonChecked
{
@@ -388,10 +396,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);
SendCheckForUpdatesConfigMSG(customaction.ToString());
RequestUpdateCheckedDate();
}
private void RequestUpdateCheckedDate()
public void RequestUpdateCheckedDate()
{
GeneralSettingsConfig.CustomActionName = "request_update_state_date";

View File

@@ -705,7 +705,7 @@
<value>Version:</value>
</data>
<data name="General_VersionLastChecked.Text" xml:space="preserve">
<value>Last checked: </value>
<value>Last successfully checked: </value>
</data>
<data name="General_Version.AutomationProperties.Name" xml:space="preserve">
<value>Version</value>

View File

@@ -133,7 +133,9 @@
<StackPanel Orientation="Horizontal"
Margin="{StaticResource SmallBottomMargin}"
AutomationProperties.LabeledBy="{Binding ElementName=General_VersionLastChecked}">
AutomationProperties.LabeledBy="{Binding ElementName=General_VersionLastChecked}"
Visibility="{Binding AutoUpdatesEnabled,
Converter={StaticResource VisibleIfTrueConverter}}">
<TextBlock x:Name="General_VersionLastChecked" x:Uid="General_VersionLastChecked" />
<TextBlock Text="{x:Bind ViewModel.UpdateCheckedDate, Mode=OneWay}"
Foreground="{ThemeResource ListViewItemForegroundPointerOver}"
@@ -144,12 +146,14 @@
Style="{StaticResource AccentButtonStyle}"
Foreground="White"
Command="{Binding CheckForUpdatesEventHandler}"
IsEnabled="{Binding AutoUpdatesEnabled}"
/>
<ToggleSwitch x:Uid="GeneralPage_ToggleSwitch_AutoDownloadUpdates"
Margin="{StaticResource MediumTopMargin}"
Visibility="{Binding Mode=TwoWay, Path=IsAdmin, Converter={StaticResource VisibleIfTrueConverter}}"
IsOn="{Binding Mode=TwoWay, Path=AutoDownloadUpdates}"/>
IsOn="{Binding Mode=TwoWay, Path=AutoDownloadUpdates}"
IsEnabled="{Binding AutoUpdatesEnabled}" />
</StackPanel>

View File

@@ -56,6 +56,11 @@ namespace Microsoft.PowerToys.Settings.UI.Views
string version = json.GetNamedString("version", string.Empty);
bool isLatest = json.GetNamedBoolean("isVersionLatest", false);
if (json.ContainsKey("version"))
{
ViewModel.RequestUpdateCheckedDate();
}
var str = string.Empty;
if (isLatest)
{