Skip to content

Commit e96280f

Browse files
committed
fix: Fix icon async problems
1 parent 88f6ee0 commit e96280f

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

VNGod/Resource/Strings/Strings.zh-CN.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,6 @@
332332
<value>确定要删除选定的本地游戏吗?这个操作无法撤销。</value>
333333
</data>
334334
<data name="WebDAVNotEnabledWarn" xml:space="preserve">
335-
<value>没有启用 WebDAV</value>
335+
<value>没有启用 WebDAV</value>
336336
</data>
337337
</root>

VNGod/Utils/IconHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace VNGod.Utils
1212
{
1313
internal static class IconHelper
1414
{
15-
public static async void GetIcons(Repo repo)
15+
public static async Task GetIcons(Repo repo)
1616
{
1717
foreach (var game in repo)
1818
{

VNGod/View/GameStorageWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private async void DownloadButton_Click(object sender, RoutedEventArgs e)
7676
// Load the metadata on disk
7777
FileHelper.ReadRepoMetadata(games);
7878
// Read icons from executable
79-
IconHelper.GetIcons(games);
79+
await IconHelper.GetIcons(games);
8080
}
8181
else
8282
{

VNGod/View/MainWindow.xaml.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ public MainWindow()
3333
timer.Tick += Timer_Tick;
3434
}
3535
#region Tools
36-
private void InitializeGameRepo(string repoPath)
36+
private async Task InitializeGameRepoAsync(string repoPath)
3737
{
3838
Resources["gameRepo"] = FileHelper.InitializeRepo(repoPath);
39-
IconHelper.GetIcons(GetRepo());
39+
await IconHelper.GetIcons(GetRepo());
4040
EnableGlobalButtons(true);
4141
}
4242
private Repo GetRepo()
@@ -146,11 +146,11 @@ private async Task SyncGameSaveAsync()
146146
syncButton.IsEnabled = true;
147147
}
148148
#endregion
149-
private void RescanButton_Click(object sender, RoutedEventArgs e)
149+
private async void RescanButton_Click(object sender, RoutedEventArgs e)
150150
{
151151
EnableGlobalButtons(false);
152152
FileHelper.ScanGames(GetRepo());
153-
IconHelper.GetIcons(GetRepo());
153+
await IconHelper.GetIcons(GetRepo());
154154
EnableGlobalButtons(true);
155155
}
156156

@@ -276,7 +276,7 @@ private async void SyncButton_Click(object sender, RoutedEventArgs e)
276276
}
277277

278278

279-
private void RepoButton_Click(object sender, RoutedEventArgs e)
279+
private async void RepoButton_Click(object sender, RoutedEventArgs e)
280280
{
281281
OpenFolderDialog openFolderDialog = new()
282282
{
@@ -292,8 +292,8 @@ private void RepoButton_Click(object sender, RoutedEventArgs e)
292292
gameStorageWindow.Close();
293293
gameStorageWindow = null;
294294
}
295-
InitializeGameRepo(openFolderDialog.FolderName);
296-
SaveAndSync(false).Wait();
295+
await InitializeGameRepoAsync(openFolderDialog.FolderName);
296+
await SaveAndSync(false);
297297
// Save repo path to settings
298298
Settings.Default.Repo = openFolderDialog.FolderName;
299299
Settings.Default.Save();
@@ -308,7 +308,7 @@ private async void Window_IsVisibleChanged(object sender, DependencyPropertyChan
308308
string repoPath = Settings.Default.Repo;
309309
if (!string.IsNullOrWhiteSpace(repoPath) && Directory.Exists(repoPath))
310310
{
311-
InitializeGameRepo(repoPath);
311+
await InitializeGameRepoAsync(repoPath);
312312
// Local may be missing, pull remote changes first
313313
if (await WebDAVHelper.InitializeClient())
314314
{
@@ -319,7 +319,7 @@ private async void Window_IsVisibleChanged(object sender, DependencyPropertyChan
319319
Growl.Warning(Strings.WebDAVInitFailed);
320320
}
321321
}
322-
GetIconButton_Click(this, new());
322+
await UpdateIconsAsync();
323323
firstLaunch = false;
324324
}
325325
if (IsVisible == true)
@@ -337,10 +337,15 @@ private void IgnoreGameItem_Click(object sender, RoutedEventArgs e)
337337
FileHelper.AddGameIgnore(repo, GetCurrentGame());
338338
repo.Remove(GetCurrentGame());
339339
}
340-
private void GetIconButton_Click(object sender, RoutedEventArgs e)
340+
private async void GetIconButton_Click(object sender, RoutedEventArgs e)
341+
{
342+
await UpdateIconsAsync();
343+
}
344+
345+
private async Task UpdateIconsAsync()
341346
{
342347
gameList.IsEnabled = false;
343-
IconHelper.GetIcons(GetRepo());
348+
await IconHelper.GetIcons(GetRepo());
344349
gameList.IsEnabled = true;
345350
}
346351

VNGod/View/SettingsWindow.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public SettingsWindow()
2323
webDavUsernameTextBox.Text = Settings.Default.WebDAVUsername;
2424
webDavPasswordBox.Password = Settings.Default.WebDAVPassword;
2525
bangumiTokenTextBox.Text = Settings.Default.BgmToken;
26-
vndbTokenTextBox.Text = Settings.Default.VNDBToken;
2726
versionBlock.Text = "Version " + Assembly.GetExecutingAssembly()
2827
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
2928
?.InformationalVersion;
@@ -45,7 +44,6 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
4544
Settings.Default.WebDAVPassword = webDavPasswordBox.Password;
4645
// Tokens
4746
Settings.Default.BgmToken = bangumiTokenTextBox.Text;
48-
Settings.Default.VNDBToken = vndbTokenTextBox.Text;
4947
Settings.Default.Save();
5048
}
5149
private void OpenLogButton_Click(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)