mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
daily card user remove aware
This commit is contained in:
@@ -175,12 +175,11 @@ internal sealed partial class CachedImage : Microsoft.UI.Xaml.Controls.Control,
|
||||
SourceName = Path.GetFileName(imageUri.ToString());
|
||||
IImageCache imageCache = this.ServiceProvider().GetRequiredService<IImageCache>();
|
||||
|
||||
string file = default;
|
||||
try
|
||||
{
|
||||
HutaoException.ThrowIf(string.IsNullOrEmpty(imageUri.Host), SH.ControlImageCachedImageInvalidResourceUri);
|
||||
ElementTheme theme = ShowAsMonoChrome ? ThemeHelper.ApplicationToElement(ThemeHelper.ElementToApplication(ActualTheme)) : ElementTheme.Default;
|
||||
file = await imageCache.GetFileFromCacheAsync(imageUri, theme).ConfigureAwait(true); // BitmapImage need to be created by main thread.
|
||||
string file = await imageCache.GetFileFromCacheAsync(imageUri, theme).ConfigureAwait(true); // BitmapImage need to be created by main thread.
|
||||
CachedName = Path.GetFileName(file);
|
||||
token.ThrowIfCancellationRequested(); // check token state to determine whether the operation should be canceled.
|
||||
return file.ToUri();
|
||||
@@ -193,7 +192,6 @@ internal sealed partial class CachedImage : Microsoft.UI.Xaml.Controls.Control,
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(file);
|
||||
Debug.WriteLine(ex);
|
||||
return default;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
<cwc:SettingsCard MinHeight="40" Padding="0,0,16,0">
|
||||
<cwc:SettingsCard.Resources>
|
||||
<x:Double x:Key="SettingsCardLeftIndention">16</x:Double>
|
||||
<x:Double x:Key="SettingsCardWrapThreshold">0</x:Double>
|
||||
<x:Double x:Key="SettingsCardWrapNoIconThreshold">0</x:Double>
|
||||
</cwc:SettingsCard.Resources>
|
||||
<cwc:SettingsCard.Header>
|
||||
<TextBlock Text="{Binding Name}" TextWrapping="NoWrap"/>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Snap.Hutao.Core.ExceptionService;
|
||||
using Snap.Hutao.Model.Entity;
|
||||
using Snap.Hutao.Service.DailyNote;
|
||||
using Snap.Hutao.Service.Metadata;
|
||||
using Snap.Hutao.Service.Notification;
|
||||
using Snap.Hutao.Service.User;
|
||||
using Snap.Hutao.UI.Xaml.View.Page;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
@@ -16,7 +18,7 @@ namespace Snap.Hutao.ViewModel.DailyNote;
|
||||
/// </summary>
|
||||
[Injection(InjectAs.Transient)]
|
||||
[ConstructorGenerated(CallBaseConstructor = true)]
|
||||
internal sealed partial class DailyNoteViewModelSlim : Abstraction.ViewModelSlim<DailyNotePage>
|
||||
internal sealed partial class DailyNoteViewModelSlim : Abstraction.ViewModelSlim<DailyNotePage>, IRecipient<UserRemovedMessage>
|
||||
{
|
||||
private readonly ITaskContext taskContext;
|
||||
private readonly IInfoBarService infoBarService;
|
||||
@@ -30,6 +32,13 @@ internal sealed partial class DailyNoteViewModelSlim : Abstraction.ViewModelSlim
|
||||
/// </summary>
|
||||
public List<DailyNoteEntry>? DailyNoteEntries { get => dailyNoteEntries; set => SetProperty(ref dailyNoteEntries, value); }
|
||||
|
||||
public void Receive(UserRemovedMessage message)
|
||||
{
|
||||
HashSet<string> removedUids = message.RemovedUser.UserGameRoles.SourceCollection.Select(role => role.GameUid).ToHashSet();
|
||||
List<DailyNoteEntry>? entries = DailyNoteEntries?.Where(entry => !removedUids.Contains(entry.Uid)).ToList();
|
||||
taskContext.BeginInvokeOnMainThread(() => { DailyNoteEntries = entries; });
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override async Task LoadAsync()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user