mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-11 10:26:57 +02:00
Formatting
This commit is contained in:
parent
45ff1daff3
commit
a9eca1ceb2
5 changed files with 8877 additions and 8894 deletions
File diff suppressed because it is too large
Load diff
|
@ -18,8 +18,10 @@ internal class ExportContext(DiscordClient discord, ExportRequest request)
|
||||||
private readonly Dictionary<Snowflake, Channel> _channelsById = new();
|
private readonly Dictionary<Snowflake, Channel> _channelsById = new();
|
||||||
private readonly Dictionary<Snowflake, Role> _rolesById = new();
|
private readonly Dictionary<Snowflake, Role> _rolesById = new();
|
||||||
|
|
||||||
private readonly ExportAssetDownloader _assetDownloader =
|
private readonly ExportAssetDownloader _assetDownloader = new(
|
||||||
new(request.AssetsDirPath, request.ShouldReuseAssets);
|
request.AssetsDirPath,
|
||||||
|
request.ShouldReuseAssets
|
||||||
|
);
|
||||||
|
|
||||||
public DiscordClient Discord { get; } = discord;
|
public DiscordClient Discord { get; } = discord;
|
||||||
|
|
||||||
|
|
|
@ -17,19 +17,18 @@ namespace DiscordChatExporter.Core.Exporting;
|
||||||
internal class JsonMessageWriter(Stream stream, ExportContext context)
|
internal class JsonMessageWriter(Stream stream, ExportContext context)
|
||||||
: MessageWriter(stream, context)
|
: MessageWriter(stream, context)
|
||||||
{
|
{
|
||||||
private readonly Utf8JsonWriter _writer =
|
private readonly Utf8JsonWriter _writer = new(
|
||||||
new(
|
stream,
|
||||||
stream,
|
new JsonWriterOptions
|
||||||
new JsonWriterOptions
|
{
|
||||||
{
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/450
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/450
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
Indented = true,
|
||||||
Indented = true,
|
// Validation errors may mask actual failures
|
||||||
// Validation errors may mask actual failures
|
// https://github.com/Tyrrrz/DiscordChatExporter/issues/413
|
||||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/413
|
SkipValidation = true,
|
||||||
SkipValidation = true,
|
}
|
||||||
}
|
);
|
||||||
);
|
|
||||||
|
|
||||||
private async ValueTask<string> FormatMarkdownAsync(
|
private async ValueTask<string> FormatMarkdownAsync(
|
||||||
string markdown,
|
string markdown,
|
||||||
|
@ -436,7 +435,11 @@ internal class JsonMessageWriter(Stream stream, ExportContext context)
|
||||||
_writer.WriteString("id", attachment.Id.ToString());
|
_writer.WriteString("id", attachment.Id.ToString());
|
||||||
_writer.WriteString(
|
_writer.WriteString(
|
||||||
"url",
|
"url",
|
||||||
await Context.ResolveAssetUrlAsync(attachment.Url, cancellationToken, message.Timestamp)
|
await Context.ResolveAssetUrlAsync(
|
||||||
|
attachment.Url,
|
||||||
|
cancellationToken,
|
||||||
|
message.Timestamp
|
||||||
|
)
|
||||||
);
|
);
|
||||||
_writer.WriteString("fileName", attachment.FileName);
|
_writer.WriteString("fileName", attachment.FileName);
|
||||||
_writer.WriteNumber("fileSizeBytes", attachment.FileSize.TotalBytes);
|
_writer.WriteNumber("fileSizeBytes", attachment.FileSize.TotalBytes);
|
||||||
|
@ -466,7 +469,11 @@ internal class JsonMessageWriter(Stream stream, ExportContext context)
|
||||||
_writer.WriteString("format", sticker.Format.ToString());
|
_writer.WriteString("format", sticker.Format.ToString());
|
||||||
_writer.WriteString(
|
_writer.WriteString(
|
||||||
"sourceUrl",
|
"sourceUrl",
|
||||||
await Context.ResolveAssetUrlAsync(sticker.SourceUrl, cancellationToken, message.Timestamp)
|
await Context.ResolveAssetUrlAsync(
|
||||||
|
sticker.SourceUrl,
|
||||||
|
cancellationToken,
|
||||||
|
message.Timestamp
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
_writer.WriteEndObject();
|
_writer.WriteEndObject();
|
||||||
|
|
|
@ -10,8 +10,9 @@ public class UrlBuilder
|
||||||
{
|
{
|
||||||
private string _path = "";
|
private string _path = "";
|
||||||
|
|
||||||
private readonly Dictionary<string, string?> _queryParameters =
|
private readonly Dictionary<string, string?> _queryParameters = new(
|
||||||
new(StringComparer.OrdinalIgnoreCase);
|
StringComparer.OrdinalIgnoreCase
|
||||||
|
);
|
||||||
|
|
||||||
public UrlBuilder SetPath(string path)
|
public UrlBuilder SetPath(string path)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,8 +6,9 @@ namespace DiscordChatExporter.Gui.Framework;
|
||||||
|
|
||||||
public abstract partial class DialogViewModelBase<T> : ViewModelBase
|
public abstract partial class DialogViewModelBase<T> : ViewModelBase
|
||||||
{
|
{
|
||||||
private readonly TaskCompletionSource<T> _closeTcs =
|
private readonly TaskCompletionSource<T> _closeTcs = new(
|
||||||
new(TaskCreationOptions.RunContinuationsAsynchronously);
|
TaskCreationOptions.RunContinuationsAsynchronously
|
||||||
|
);
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private T? _dialogResult;
|
private T? _dialogResult;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue