mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
Auto-updating: add text for "Last checked" (#8645)
This commit is contained in:
@@ -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