mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
Auto-updating: add text for "Last checked" (#8645)
This commit is contained in:
@@ -99,6 +99,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
private bool _autoDownloadUpdates;
|
||||
|
||||
private string _latestAvailableVersion = string.Empty;
|
||||
private string _updateCheckedDate = string.Empty;
|
||||
|
||||
// Gets or sets a value indicating whether packaged.
|
||||
public bool Packaged
|
||||
@@ -333,6 +334,24 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public string UpdateCheckedDate
|
||||
{
|
||||
get
|
||||
{
|
||||
RequestUpdateCheckedDate();
|
||||
return _updateCheckedDate;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_updateCheckedDate != value)
|
||||
{
|
||||
_updateCheckedDate = value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Temp string. Appears when a user clicks "Check for updates" button and shows latest version available on the Github.
|
||||
public string LatestAvailableVersion
|
||||
{
|
||||
@@ -368,6 +387,17 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
||||
GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);
|
||||
|
||||
SendCheckForUpdatesConfigMSG(customaction.ToString());
|
||||
RequestUpdateCheckedDate();
|
||||
}
|
||||
|
||||
private void RequestUpdateCheckedDate()
|
||||
{
|
||||
GeneralSettingsConfig.CustomActionName = "request_update_state_date";
|
||||
|
||||
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
||||
GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);
|
||||
|
||||
SendCheckForUpdatesConfigMSG(customaction.ToString());
|
||||
}
|
||||
|
||||
|
||||
@@ -704,6 +704,9 @@
|
||||
<data name="General_Version.Text" xml:space="preserve">
|
||||
<value>Version:</value>
|
||||
</data>
|
||||
<data name="General_VersionLastChecked.Text" xml:space="preserve">
|
||||
<value>Last checked: </value>
|
||||
</data>
|
||||
<data name="General_Version.AutomationProperties.Name" xml:space="preserve">
|
||||
<value>Version</value>
|
||||
</data>
|
||||
@@ -873,4 +876,4 @@
|
||||
<data name="ColorPicker_ShowColorName.Content" xml:space="preserve">
|
||||
<value>Show color name</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
|
||||
@@ -127,6 +127,14 @@
|
||||
Margin="16,0,0,0" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Margin="{StaticResource SmallBottomMargin}"
|
||||
AutomationProperties.LabeledBy="{Binding ElementName=General_VersionLastChecked}">
|
||||
<TextBlock x:Name="General_VersionLastChecked" x:Uid="General_VersionLastChecked" />
|
||||
<TextBlock Text="{x:Bind ViewModel.UpdateCheckedDate, Mode=OneWay}"
|
||||
Foreground="{ThemeResource ListViewItemForegroundPointerOver}"
|
||||
Margin="6,0" />
|
||||
</StackPanel>
|
||||
|
||||
<Button x:Uid="GeneralPage_CheckForUpdates"
|
||||
Style="{StaticResource AccentButtonStyle}"
|
||||
|
||||
@@ -53,8 +53,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
{
|
||||
try
|
||||
{
|
||||
string version = json.GetNamedString("version");
|
||||
bool isLatest = json.GetNamedBoolean("isVersionLatest");
|
||||
string version = json.GetNamedString("version", string.Empty);
|
||||
bool isLatest = json.GetNamedBoolean("isVersionLatest", false);
|
||||
|
||||
var str = string.Empty;
|
||||
if (isLatest)
|
||||
@@ -71,7 +71,17 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
}
|
||||
|
||||
// Using CurrentCulture since this is user-facing
|
||||
ViewModel.LatestAvailableVersion = string.Format(CultureInfo.CurrentCulture, str);
|
||||
if (!string.IsNullOrEmpty(str))
|
||||
{
|
||||
ViewModel.LatestAvailableVersion = string.Format(CultureInfo.CurrentCulture, str);
|
||||
}
|
||||
|
||||
string updateStateDate = json.GetNamedString("updateStateDate", string.Empty);
|
||||
if (!string.IsNullOrEmpty(updateStateDate) && long.TryParse(updateStateDate, out var uTCTime))
|
||||
{
|
||||
var localTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(uTCTime).ToLocalTime();
|
||||
ViewModel.UpdateCheckedDate = localTime.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user