mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-31 09:33:03 -06:00
Cleanup: fix filename typo, replace AsyncNonKeyedLocker, drop WithIndex(), use ProcessStartInfo ctor arg (#1492)
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
parent
7ff2347df1
commit
21c2398e2a
|
|
@ -34,7 +34,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="chatlog__message-group">
|
<div class="chatlog__message-group">
|
||||||
@foreach (var (message, i) in Messages.WithIndex())
|
@foreach (var (i, message) in Messages.Index())
|
||||||
{
|
{
|
||||||
var isFirst = i == 0;
|
var isFirst = i == 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ internal class PlainTextMessageWriter(Stream stream, ExportContext context)
|
||||||
|
|
||||||
await _writer.WriteLineAsync("{Reactions}");
|
await _writer.WriteLineAsync("{Reactions}");
|
||||||
|
|
||||||
foreach (var (reaction, i) in reactions.WithIndex())
|
foreach (var (i, reaction) in reactions.Index())
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,6 @@ public static class CollectionExtensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension<T>(IEnumerable<T> source)
|
|
||||||
{
|
|
||||||
public IEnumerable<(T value, int index)> WithIndex()
|
|
||||||
{
|
|
||||||
var i = 0;
|
|
||||||
foreach (var o in source)
|
|
||||||
yield return (o, i++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension<T>(IEnumerable<T?> source)
|
extension<T>(IEnumerable<T?> source)
|
||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AsyncKeyedLock;
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using DialogHostAvalonia;
|
using DialogHostAvalonia;
|
||||||
|
|
@ -13,11 +13,12 @@ namespace DiscordChatExporter.Gui.Framework;
|
||||||
|
|
||||||
public class DialogManager : IDisposable
|
public class DialogManager : IDisposable
|
||||||
{
|
{
|
||||||
private readonly AsyncNonKeyedLocker _dialogLock = new();
|
private readonly SemaphoreSlim _dialogLock = new(1, 1);
|
||||||
|
|
||||||
public async Task<T?> ShowDialogAsync<T>(DialogViewModelBase<T> dialog)
|
public async Task<T?> ShowDialogAsync<T>(DialogViewModelBase<T> dialog)
|
||||||
{
|
{
|
||||||
using (await _dialogLock.LockAsync())
|
await _dialogLock.WaitAsync();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
await DialogHost.Show(
|
await DialogHost.Show(
|
||||||
dialog,
|
dialog,
|
||||||
|
|
@ -44,6 +45,10 @@ public class DialogManager : IDisposable
|
||||||
|
|
||||||
return dialog.DialogResult;
|
return dialog.DialogResult;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_dialogLock.Release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string?> PromptSaveFilePathAsync(
|
public async Task<string?> PromptSaveFilePathAsync(
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ internal static class ProcessExtensions
|
||||||
public static void StartShellExecute(string path)
|
public static void StartShellExecute(string path)
|
||||||
{
|
{
|
||||||
using var process = new Process();
|
using var process = new Process();
|
||||||
process.StartInfo = new ProcessStartInfo { FileName = path, UseShellExecute = true };
|
process.StartInfo = new ProcessStartInfo(path) { UseShellExecute = true };
|
||||||
|
|
||||||
process.Start();
|
process.Start();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue