Skip to content

Commit

Permalink
optimize cache image placeholder presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Dec 31, 2023
1 parent b49cd92 commit d2c33cf
Show file tree
Hide file tree
Showing 13 changed files with 248 additions and 251 deletions.
2 changes: 1 addition & 1 deletion src/Snap.Hutao/Snap.Hutao/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
if (firstInstance.IsCurrent)
{
logger.LogInformation(ConsoleBanner);
LogDiagnosticInformation();

// manually invoke
activation.NonRedirectToActivate(firstInstance, activatedEventArgs);
activation.InitializeWith(firstInstance);

LogDiagnosticInformation();
serviceProvider.GetRequiredService<IJumpListInterop>().ConfigureAsync().SafeForget();
}
else
Expand Down
9 changes: 3 additions & 6 deletions src/Snap.Hutao/Snap.Hutao/Control/Image/CachedImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Media.Imaging;
using Snap.Hutao.Core.Caching;
using Snap.Hutao.Model.Metadata.Converter;
using Snap.Hutao.Web;
using System.Runtime.InteropServices;

namespace Snap.Hutao.Control.Image;
Expand Down Expand Up @@ -40,12 +42,7 @@ public CachedImage()
{
// The image is corrupted, remove it.
imageCache.Remove(imageUri);
return null;
}
catch (OperationCanceledException)
{
// task was explicitly canceled
return null;
return default;
}
}
}
1 change: 1 addition & 0 deletions src/Snap.Hutao/Snap.Hutao/Control/Image/CachedImage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
CornerRadius="{TemplateBinding CornerRadius}">
<Image
Name="PlaceholderImage"
Margin="{TemplateBinding PlaceholderMargin}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Source="{TemplateBinding PlaceholderSource}"
Expand Down
Loading

0 comments on commit d2c33cf

Please sign in to comment.