Skip to content

Commit

Permalink
Merge pull request #1214 from DGP-Studio/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx authored Dec 23, 2023
2 parents 6ee8230 + d293149 commit b115267
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 44 deletions.
1 change: 1 addition & 0 deletions src/Snap.Hutao/Snap.Hutao/Control/Theme/Uri.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
<x:String x:Key="UI_EmotionIcon250">https://api.snapgenshin.com/static/raw/EmotionIcon/UI_EmotionIcon250.png</x:String>
<x:String x:Key="UI_EmotionIcon272">https://api.snapgenshin.com/static/raw/EmotionIcon/UI_EmotionIcon272.png</x:String>
<x:String x:Key="UI_EmotionIcon293">https://api.snapgenshin.com/static/raw/EmotionIcon/UI_EmotionIcon293.png</x:String>
<x:String x:Key="UI_EmotionIcon445">https://api.snapgenshin.com/static/raw/EmotionIcon/UI_EmotionIcon445.png</x:String>
</ResourceDictionary>
19 changes: 0 additions & 19 deletions src/Snap.Hutao/Snap.Hutao/Core/Threading/Throttler.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Snap.Hutao/Snap.Hutao/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Identity
Name="60568DGPStudio.SnapHutao"
Publisher="CN=35C8E923-85DF-49A7-9172-B39DC6312C52"
Version="1.9.0.0" />
Version="1.9.1.0" />

<Properties>
<DisplayName>Snap Hutao</DisplayName>
Expand Down
2 changes: 1 addition & 1 deletion src/Snap.Hutao/Snap.Hutao/Package.development.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Identity
Name="60568DGPStudio.SnapHutaoDev"
Publisher="CN=35C8E923-85DF-49A7-9172-B39DC6312C52"
Version="1.9.0.0" />
Version="1.9.1.0" />

<Properties>
<DisplayName>Snap Hutao Dev</DisplayName>
Expand Down
3 changes: 3 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2144,6 +2144,9 @@
<data name="ViewPageLaunchGameResourcePreDownloadHeader" xml:space="preserve">
<value>预下载</value>
</data>
<data name="ViewPageLaunchGameSelectGamePath" xml:space="preserve">
<value>选择游戏路径</value>
</data>
<data name="ViewPageLaunchGameSwitchAccountAttachUidNull" xml:space="preserve">
<value>该账号尚未绑定实时便笺通知 UID</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async ValueTask<ObservableCollection<DailyNoteEntry>> GetDailyNoteEntryCo

List<DailyNoteEntry> entryList = await dailyNoteDbService.GetDailyNoteEntryIncludeUserListAsync().ConfigureAwait(false);
entryList.ForEach(entry => { entry.UserGameRole = userService.GetUserGameRoleByUid(entry.Uid); });
entries = new(entryList);
entries = entryList.ToObservableCollection();
}

return entries;
Expand Down
2 changes: 1 addition & 1 deletion src/Snap.Hutao/Snap.Hutao/Service/Update/UpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async ValueTask<bool> CheckForUpdateAndDownloadAsync(IProgress<UpdateStat

progress.Report(new(versionInformation.Version.ToString(), 0, 0));

if (versionInformation.Sha256 is not { } sha256)
if (versionInformation.Sha256 is not { Length: > 0 } sha256)
{
return false;
}
Expand Down
25 changes: 11 additions & 14 deletions src/Snap.Hutao/Snap.Hutao/Service/User/UserCollectionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ namespace Snap.Hutao.Service.User;

[ConstructorGenerated]
[Injection(InjectAs.Singleton, typeof(IUserCollectionService))]
internal sealed partial class UserCollectionService : IUserCollectionService
internal sealed partial class UserCollectionService : IUserCollectionService, IDisposable
{
private readonly ScopedDbCurrent<BindingUser, Model.Entity.User, UserChangedMessage> dbCurrent;
private readonly IUserInitializationService userInitializationService;
private readonly IUserDbService userDbService;
private readonly ITaskContext taskContext;
private readonly IMessenger messenger;

private readonly Throttler throttler = new();
private readonly SemaphoreSlim throttler = new(1);

private ObservableCollection<BindingUser>? userCollection;
private Dictionary<string, BindingUser>? midUserMap;
Expand All @@ -38,7 +38,9 @@ public BindingUser? CurrentUser

public async ValueTask<ObservableCollection<BindingUser>> GetUserCollectionAsync()
{
using (await throttler.ThrottleAsync().ConfigureAwait(false))
// Force run in background thread, otherwise will cause reentrance
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding);
using (await throttler.EnterAsync().ConfigureAwait(false))
{
if (userCollection is null)
{
Expand Down Expand Up @@ -131,17 +133,7 @@ public async ValueTask RemoveUserAsync(BindingUser user)
return default;
}

try
{
return uidUserGameRoleMap[uid];
}
catch (InvalidOperationException)
{
// Sequence contains more than one matching element
// TODO: return a specialize UserGameRole to indicate error
}

return default;
return uidUserGameRoleMap.GetValueOrDefault(uid);
}

public bool TryGetUserByMid(string mid, [NotNullWhen(true)] out BindingUser? user)
Expand Down Expand Up @@ -186,4 +178,9 @@ public async ValueTask<ValueResult<UserOptionResult, string>> TryCreateAndAddUse
ArgumentNullException.ThrowIfNull(newUser.UserInfo);
return new(UserOptionResult.Added, newUser.UserInfo.Uid);
}

public void Dispose()
{
throttler.Dispose();
}
}
13 changes: 12 additions & 1 deletion src/Snap.Hutao/Snap.Hutao/View/Page/LaunchGamePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
xmlns:shccs="using:Snap.Hutao.Control.Collection.Selector"
xmlns:shch="using:Snap.Hutao.Control.Helper"
xmlns:shci="using:Snap.Hutao.Control.Image"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
xmlns:shvc="using:Snap.Hutao.View.Control"
xmlns:shvg="using:Snap.Hutao.ViewModel.Game"
Expand Down Expand Up @@ -346,10 +347,20 @@
</Grid>
<Grid Visibility="{Binding GamePathSelectedAndValid, Converter={StaticResource BoolToVisibilityRevertConverter}}">
<StackPanel
MaxWidth="600"
Margin="128,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Spacing="3">
<shci:CachedImage
Width="120"
Height="120"
EnableLazyLoading="False"
Source="{StaticResource UI_EmotionIcon445}"/>
<TextBlock
Margin="0,5,0,21"
HorizontalAlignment="Center"
Style="{StaticResource SubtitleTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewPageLaunchGameSelectGamePath}"/>
<Border Style="{ThemeResource BorderCardStyle}">
<ListView
ItemTemplate="{StaticResource GamePathEntryListTemplate}"
Expand Down
12 changes: 6 additions & 6 deletions src/Snap.Hutao/Snap.Hutao/View/Page/SettingPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@
Background="{ThemeResource SystemFillColorSuccessBackgroundBrush}"
Description="{shcm:ResourceString Name=ViewPageSettingHutaoPassportLicensedDeveloperDescription}"
Header="{shcm:ResourceString Name=ViewPageSettingHutaoPassportLicensedDeveloperHeader}"
Visibility="{Binding UserOptions.IsLicensedDeveloper, Converter={StaticResource BoolToVisibilityConverter}}"/>
<cwc:SettingsCard
Background="{ThemeResource SystemFillColorSuccessBackgroundBrush}"
Description="{shcm:ResourceString Name=ViewPageSettingHutaoPassportMaintainerDescription}"
Header="{shcm:ResourceString Name=ViewPageSettingHutaoPassportMaintainerHeader}"
Visibility="{Binding UserOptions.IsMaintainer, Converter={StaticResource BoolToVisibilityConverter}}">
Visibility="{Binding UserOptions.IsLicensedDeveloper, Converter={StaticResource BoolToVisibilityConverter}}">
<Button
Command="{Binding OpenTestPageCommand}"
Content="TEST"
Style="{ThemeResource SettingButtonStyle}"/>
</cwc:SettingsCard>
<cwc:SettingsCard
Background="{ThemeResource SystemFillColorSuccessBackgroundBrush}"
Description="{shcm:ResourceString Name=ViewPageSettingHutaoPassportMaintainerDescription}"
Header="{shcm:ResourceString Name=ViewPageSettingHutaoPassportMaintainerHeader}"
Visibility="{Binding UserOptions.IsMaintainer, Converter={StaticResource BoolToVisibilityConverter}}"/>
<cwc:SettingsCard Description="{Binding UserOptions.GachaLogExpireAtSlim}" Header="{shcm:ResourceString Name=ViewPageSettingHutaoPassportGachaLogExpiredAtHeader}"/>
<cwc:SettingsCard
Command="{Binding Passport.OpenRedeemWebsiteCommand}"
Expand Down

0 comments on commit b115267

Please sign in to comment.