Auto-updating: add text for "Last checked" (#8645)

This commit is contained in:
Andrey Nekrasov
2020-12-17 19:38:23 +03:00
committed by GitHub
parent 24141abde2
commit e58ff6c71c
5 changed files with 75 additions and 6 deletions

View File

@@ -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}"

View File

@@ -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)
{