Remove Tyrrrz.Extensions package

This commit is contained in:
Tyrrrz 2021-11-15 18:50:46 +02:00
parent 720e53caab
commit 1db2bb4170
8 changed files with 20 additions and 28 deletions

View file

@ -9,7 +9,6 @@
<PackageReference Include="CliFx" Version="2.0.6" /> <PackageReference Include="CliFx" Version="2.0.6" />
<PackageReference Include="Spectre.Console" Version="0.42.0" /> <PackageReference Include="Spectre.Console" Version="0.42.0" />
<PackageReference Include="Gress" Version="1.2.0" /> <PackageReference Include="Gress" Version="1.2.0" />
<PackageReference Include="Tyrrrz.Extensions" Version="1.6.5" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -3,7 +3,6 @@ using System.Text.Json;
using DiscordChatExporter.Core.Discord.Data.Common; using DiscordChatExporter.Core.Discord.Data.Common;
using DiscordChatExporter.Core.Utils.Extensions; using DiscordChatExporter.Core.Utils.Extensions;
using JsonExtensions.Reading; using JsonExtensions.Reading;
using Tyrrrz.Extensions;
namespace DiscordChatExporter.Core.Discord.Data namespace DiscordChatExporter.Core.Discord.Data
{ {
@ -55,7 +54,7 @@ namespace DiscordChatExporter.Core.Discord.Data
json.GetPropertyOrNull("name")?.GetStringOrNull() ?? json.GetPropertyOrNull("name")?.GetStringOrNull() ??
// DM channel // DM channel
json.GetPropertyOrNull("recipients")?.EnumerateArray().Select(User.Parse).Select(u => u.Name) json.GetPropertyOrNull("recipients")?.EnumerateArray().Select(User.Parse).Select(u => u.Name)
.JoinToString(", ") ?? .Pipe(s => string.Join(", ", s)) ??
// Fallback // Fallback
id.ToString(); id.ToString();

View file

@ -3,7 +3,6 @@ using System.Text.Json;
using DiscordChatExporter.Core.Utils; using DiscordChatExporter.Core.Utils;
using DiscordChatExporter.Core.Utils.Extensions; using DiscordChatExporter.Core.Utils.Extensions;
using JsonExtensions.Reading; using JsonExtensions.Reading;
using Tyrrrz.Extensions;
namespace DiscordChatExporter.Core.Discord.Data namespace DiscordChatExporter.Core.Discord.Data
{ {
@ -24,12 +23,13 @@ namespace DiscordChatExporter.Core.Discord.Data
public partial record Emoji public partial record Emoji
{ {
private static string GetTwemojiName(string name) => name private static string GetTwemojiName(string name) => string.Join("-",
name
.GetRunes() .GetRunes()
// Variant selector rune is skipped in Twemoji names // Variant selector rune is skipped in Twemoji names
.Where(r => r.Value != 0xfe0f) .Where(r => r.Value != 0xfe0f)
.Select(r => r.Value.ToString("x")) .Select(r => r.Value.ToString("x"))
.JoinToString("-"); );
public static string GetImageUrl(string? id, string name, bool isAnimated) public static string GetImageUrl(string? id, string name, bool isAnimated)
{ {

View file

@ -9,7 +9,6 @@
<PackageReference Include="MiniRazor.CodeGen" Version="2.2.0" /> <PackageReference Include="MiniRazor.CodeGen" Version="2.2.0" />
<PackageReference Include="Polly" Version="7.2.2" /> <PackageReference Include="Polly" Version="7.2.2" />
<PackageReference Include="Superpower" Version="3.0.0" /> <PackageReference Include="Superpower" Version="3.0.0" />
<PackageReference Include="Tyrrrz.Extensions" Version="1.6.5" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -6,7 +6,6 @@ using System.Threading.Tasks;
using DiscordChatExporter.Core.Discord.Data; using DiscordChatExporter.Core.Discord.Data;
using DiscordChatExporter.Core.Discord.Data.Embeds; using DiscordChatExporter.Core.Discord.Data.Embeds;
using DiscordChatExporter.Core.Exporting.Writers.MarkdownVisitors; using DiscordChatExporter.Core.Exporting.Writers.MarkdownVisitors;
using Tyrrrz.Extensions;
namespace DiscordChatExporter.Core.Exporting.Writers namespace DiscordChatExporter.Core.Exporting.Writers
{ {
@ -125,7 +124,7 @@ namespace DiscordChatExporter.Core.Exporting.Writers
public override async ValueTask WritePreambleAsync(CancellationToken cancellationToken = default) public override async ValueTask WritePreambleAsync(CancellationToken cancellationToken = default)
{ {
await _writer.WriteLineAsync('='.Repeat(62)); await _writer.WriteLineAsync(new string('=', 62));
await _writer.WriteLineAsync($"Guild: {Context.Request.Guild.Name}"); await _writer.WriteLineAsync($"Guild: {Context.Request.Guild.Name}");
await _writer.WriteLineAsync($"Channel: {Context.Request.Channel.Category.Name} / {Context.Request.Channel.Name}"); await _writer.WriteLineAsync($"Channel: {Context.Request.Channel.Category.Name} / {Context.Request.Channel.Name}");
@ -138,7 +137,7 @@ namespace DiscordChatExporter.Core.Exporting.Writers
if (Context.Request.Before is not null) if (Context.Request.Before is not null)
await _writer.WriteLineAsync($"Before: {Context.FormatDate(Context.Request.Before.Value.ToDate())}"); await _writer.WriteLineAsync($"Before: {Context.FormatDate(Context.Request.Before.Value.ToDate())}");
await _writer.WriteLineAsync('='.Repeat(62)); await _writer.WriteLineAsync(new string('=', 62));
await _writer.WriteLineAsync(); await _writer.WriteLineAsync();
} }
@ -167,9 +166,9 @@ namespace DiscordChatExporter.Core.Exporting.Writers
public override async ValueTask WritePostambleAsync(CancellationToken cancellationToken = default) public override async ValueTask WritePostambleAsync(CancellationToken cancellationToken = default)
{ {
await _writer.WriteLineAsync('='.Repeat(62)); await _writer.WriteLineAsync(new string('=', 62));
await _writer.WriteLineAsync($"Exported {MessagesWritten:N0} message(s)"); await _writer.WriteLineAsync($"Exported {MessagesWritten:N0} message(s)");
await _writer.WriteLineAsync('='.Repeat(62)); await _writer.WriteLineAsync(new string('=', 62));
} }
public override async ValueTask DisposeAsync() public override async ValueTask DisposeAsync()

View file

@ -24,7 +24,6 @@
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.0" /> <PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.0" />
<PackageReference Include="Onova" Version="2.6.2" /> <PackageReference Include="Onova" Version="2.6.2" />
<PackageReference Include="Stylet" Version="1.3.6" /> <PackageReference Include="Stylet" Version="1.3.6" />
<PackageReference Include="Tyrrrz.Extensions" Version="1.6.5" />
<PackageReference Include="Tyrrrz.Settings" Version="1.3.4" /> <PackageReference Include="Tyrrrz.Settings" Version="1.3.4" />
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" PrivateAssets="all" /> <PackageReference Include="PropertyChanged.Fody" Version="3.4.0" PrivateAssets="all" />
</ItemGroup> </ItemGroup>

View file

@ -1,6 +1,6 @@
using DiscordChatExporter.Gui.Services; using System;
using DiscordChatExporter.Gui.Services;
using DiscordChatExporter.Gui.ViewModels.Framework; using DiscordChatExporter.Gui.ViewModels.Framework;
using Tyrrrz.Extensions;
namespace DiscordChatExporter.Gui.ViewModels.Dialogs namespace DiscordChatExporter.Gui.ViewModels.Dialogs
{ {
@ -35,7 +35,7 @@ namespace DiscordChatExporter.Gui.ViewModels.Dialogs
public int ParallelLimit public int ParallelLimit
{ {
get => _settingsService.ParallelLimit; get => _settingsService.ParallelLimit;
set => _settingsService.ParallelLimit = value.Clamp(1, 10); set => _settingsService.ParallelLimit = Math.Clamp(value, 1, 10);
} }
public bool ShouldReuseMedia public bool ShouldReuseMedia
@ -44,9 +44,7 @@ namespace DiscordChatExporter.Gui.ViewModels.Dialogs
set => _settingsService.ShouldReuseMedia = value; set => _settingsService.ShouldReuseMedia = value;
} }
public SettingsViewModel(SettingsService settingsService) public SettingsViewModel(SettingsService settingsService) =>
{
_settingsService = settingsService; _settingsService = settingsService;
} }
}
} }

View file

@ -15,7 +15,6 @@ using DiscordChatExporter.Gui.ViewModels.Framework;
using Gress; using Gress;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
using Stylet; using Stylet;
using Tyrrrz.Extensions;
namespace DiscordChatExporter.Gui.ViewModels namespace DiscordChatExporter.Gui.ViewModels
{ {
@ -69,11 +68,11 @@ namespace DiscordChatExporter.Gui.ViewModels
); );
ProgressManager.Bind(o => o.IsActive, (_, _) => ProgressManager.Bind(o => o.IsActive, (_, _) =>
IsProgressIndeterminate = ProgressManager.IsActive && ProgressManager.Progress.IsEither(0, 1) IsProgressIndeterminate = ProgressManager.IsActive && ProgressManager.Progress is <= 0 or >= 1
); );
ProgressManager.Bind(o => o.Progress, (_, _) => ProgressManager.Bind(o => o.Progress, (_, _) =>
IsProgressIndeterminate = ProgressManager.IsActive && ProgressManager.Progress.IsEither(0, 1) IsProgressIndeterminate = ProgressManager.IsActive && ProgressManager.Progress is <= 0 or >= 1
); );
} }
@ -243,7 +242,7 @@ namespace DiscordChatExporter.Gui.ViewModels
{ {
operation.Dispose(); operation.Dispose();
} }
}, _settingsService.ParallelLimit.ClampMin(1)); }, Math.Max(1, _settingsService.ParallelLimit));
// Notify of overall completion // Notify of overall completion
if (successfulExportCount > 0) if (successfulExportCount > 0)