mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-23 11:16:59 -04:00
Use is null
/is not null
This commit is contained in:
parent
ebe4d58a42
commit
3aef7faa1e
17 changed files with 59 additions and 59 deletions
|
@ -194,7 +194,7 @@ namespace DiscordChatExporter.Core.Discord
|
||||||
|
|
||||||
var parentId = response.GetPropertyOrNull("parent_id")?.GetString().Pipe(Snowflake.Parse);
|
var parentId = response.GetPropertyOrNull("parent_id")?.GetString().Pipe(Snowflake.Parse);
|
||||||
|
|
||||||
var category = parentId != null
|
var category = parentId is not null
|
||||||
? await GetChannelCategoryAsync(parentId.Value)
|
? await GetChannelCategoryAsync(parentId.Value)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ namespace DiscordChatExporter.Core.Discord
|
||||||
// will not appear in the output.
|
// will not appear in the output.
|
||||||
// Additionally, it provides the date of the last message, which is used to calculate progress.
|
// Additionally, it provides the date of the last message, which is used to calculate progress.
|
||||||
var lastMessage = await TryGetLastMessageAsync(channelId, before);
|
var lastMessage = await TryGetLastMessageAsync(channelId, before);
|
||||||
if (lastMessage == null || lastMessage.Timestamp < after?.ToDate())
|
if (lastMessage is null || lastMessage.Timestamp < after?.ToDate())
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
// Keep track of first message in range in order to calculate progress
|
// Keep track of first message in range in order to calculate progress
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace DiscordChatExporter.Core.Exporting
|
||||||
var roles = member?.RoleIds.Join(Roles, i => i, r => r.Id, (_, role) => role);
|
var roles = member?.RoleIds.Join(Roles, i => i, r => r.Id, (_, role) => role);
|
||||||
|
|
||||||
return roles?
|
return roles?
|
||||||
.Where(r => r.Color != null)
|
.Where(r => r.Color is not null)
|
||||||
.OrderByDescending(r => r.Position)
|
.OrderByDescending(r => r.Position)
|
||||||
.Select(r => r.Color)
|
.Select(r => r.Color)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
|
@ -127,17 +127,17 @@ namespace DiscordChatExporter.Core.Exporting
|
||||||
buffer.Append($"{guild.Name} - {channel.Category.Name} - {channel.Name} [{channel.Id}]");
|
buffer.Append($"{guild.Name} - {channel.Category.Name} - {channel.Name} [{channel.Id}]");
|
||||||
|
|
||||||
// Date range
|
// Date range
|
||||||
if (after != null || before != null)
|
if (after is not null || before is not null)
|
||||||
{
|
{
|
||||||
buffer.Append(" (");
|
buffer.Append(" (");
|
||||||
|
|
||||||
// Both 'after' and 'before' are set
|
// Both 'after' and 'before' are set
|
||||||
if (after != null && before != null)
|
if (after is not null && before is not null)
|
||||||
{
|
{
|
||||||
buffer.Append($"{after?.ToDate():yyyy-MM-dd} to {before?.ToDate():yyyy-MM-dd}");
|
buffer.Append($"{after?.ToDate():yyyy-MM-dd} to {before?.ToDate():yyyy-MM-dd}");
|
||||||
}
|
}
|
||||||
// Only 'after' is set
|
// Only 'after' is set
|
||||||
else if (after != null)
|
else if (after is not null)
|
||||||
{
|
{
|
||||||
buffer.Append($"after {after?.ToDate():yyyy-MM-dd}");
|
buffer.Append($"after {after?.ToDate():yyyy-MM-dd}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace DiscordChatExporter.Core.Exporting
|
||||||
: (DateTimeOffset?) null
|
: (DateTimeOffset?) null
|
||||||
);
|
);
|
||||||
|
|
||||||
if (lastModified != null)
|
if (lastModified is not null)
|
||||||
{
|
{
|
||||||
File.SetCreationTimeUtc(filePath, lastModified.Value.UtcDateTime);
|
File.SetCreationTimeUtc(filePath, lastModified.Value.UtcDateTime);
|
||||||
File.SetLastWriteTimeUtc(filePath, lastModified.Value.UtcDateTime);
|
File.SetLastWriteTimeUtc(filePath, lastModified.Value.UtcDateTime);
|
||||||
|
|
|
@ -21,13 +21,13 @@ namespace DiscordChatExporter.Core.Exporting
|
||||||
|
|
||||||
private bool IsPartitionLimitReached() =>
|
private bool IsPartitionLimitReached() =>
|
||||||
_messageCount > 0 &&
|
_messageCount > 0 &&
|
||||||
_context.Request.PartitionLimit != null &&
|
_context.Request.PartitionLimit is not null &&
|
||||||
_context.Request.PartitionLimit != 0 &&
|
_context.Request.PartitionLimit != 0 &&
|
||||||
_messageCount % _context.Request.PartitionLimit == 0;
|
_messageCount % _context.Request.PartitionLimit == 0;
|
||||||
|
|
||||||
private async ValueTask ResetWriterAsync()
|
private async ValueTask ResetWriterAsync()
|
||||||
{
|
{
|
||||||
if (_writer != null)
|
if (_writer is not null)
|
||||||
{
|
{
|
||||||
await _writer.WritePostambleAsync();
|
await _writer.WritePostambleAsync();
|
||||||
await _writer.DisposeAsync();
|
await _writer.DisposeAsync();
|
||||||
|
@ -45,7 +45,7 @@ namespace DiscordChatExporter.Core.Exporting
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writer is still valid - return
|
// Writer is still valid - return
|
||||||
if (_writer != null)
|
if (_writer is not null)
|
||||||
return _writer;
|
return _writer;
|
||||||
|
|
||||||
var filePath = GetPartitionFilePath(_context.Request.OutputBaseFilePath, _partitionIndex);
|
var filePath = GetPartitionFilePath(_context.Request.OutputBaseFilePath, _partitionIndex);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
var userColor = Model.ExportContext.TryGetUserColor(Model.MessageGroup.Author.Id);
|
var userColor = Model.ExportContext.TryGetUserColor(Model.MessageGroup.Author.Id);
|
||||||
|
|
||||||
var userColorStyle = userColor != null
|
var userColorStyle = userColor is not null
|
||||||
? $"color: rgb({userColor?.R},{userColor?.G},{userColor?.B})"
|
? $"color: rgb({userColor?.R},{userColor?.G},{userColor?.B})"
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
@ -25,19 +25,19 @@
|
||||||
? Model.MessageGroup.Author.Name
|
? Model.MessageGroup.Author.Name
|
||||||
: userMember?.Nick ?? Model.MessageGroup.Author.Name;
|
: userMember?.Nick ?? Model.MessageGroup.Author.Name;
|
||||||
|
|
||||||
var referencedUserMember = Model.MessageGroup.ReferencedMessage != null
|
var referencedUserMember = Model.MessageGroup.ReferencedMessage is not null
|
||||||
? Model.ExportContext.TryGetMember(Model.MessageGroup.ReferencedMessage.Author.Id)
|
? Model.ExportContext.TryGetMember(Model.MessageGroup.ReferencedMessage.Author.Id)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
var referencedUserColor = Model.MessageGroup.ReferencedMessage != null
|
var referencedUserColor = Model.MessageGroup.ReferencedMessage is not null
|
||||||
? Model.ExportContext.TryGetUserColor(Model.MessageGroup.ReferencedMessage.Author.Id)
|
? Model.ExportContext.TryGetUserColor(Model.MessageGroup.ReferencedMessage.Author.Id)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
var referencedUserColorStyle = referencedUserColor != null
|
var referencedUserColorStyle = referencedUserColor is not null
|
||||||
? $"color: rgb({referencedUserColor?.R},{referencedUserColor?.G},{referencedUserColor?.B})"
|
? $"color: rgb({referencedUserColor?.R},{referencedUserColor?.G},{referencedUserColor?.B})"
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
var referencedUserNick = Model.MessageGroup.ReferencedMessage != null
|
var referencedUserNick = Model.MessageGroup.ReferencedMessage is not null
|
||||||
? Model.MessageGroup.ReferencedMessage.Author.IsBot
|
? Model.MessageGroup.ReferencedMessage.Author.IsBot
|
||||||
? Model.MessageGroup.ReferencedMessage.Author.Name
|
? Model.MessageGroup.ReferencedMessage.Author.Name
|
||||||
: referencedUserMember?.Nick ?? Model.MessageGroup.ReferencedMessage.Author.Name
|
: referencedUserMember?.Nick ?? Model.MessageGroup.ReferencedMessage.Author.Name
|
||||||
|
@ -45,12 +45,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="chatlog__message-group">
|
<div class="chatlog__message-group">
|
||||||
@if (Model.MessageGroup.Reference != null)
|
@if (Model.MessageGroup.Reference is not null)
|
||||||
{
|
{
|
||||||
<div class="chatlog__reference-symbol">
|
<div class="chatlog__reference-symbol">
|
||||||
</div>
|
</div>
|
||||||
<div class="chatlog__reference">
|
<div class="chatlog__reference">
|
||||||
@if (Model.MessageGroup.ReferencedMessage != null)
|
@if (Model.MessageGroup.ReferencedMessage is not null)
|
||||||
{
|
{
|
||||||
<img class="chatlog__reference-avatar" src="@await ResolveUrlAsync(Model.MessageGroup.ReferencedMessage.Author.AvatarUrl)" alt="Avatar">
|
<img class="chatlog__reference-avatar" src="@await ResolveUrlAsync(Model.MessageGroup.ReferencedMessage.Author.AvatarUrl)" alt="Avatar">
|
||||||
<span class="chatlog__reference-name" title="@Model.MessageGroup.ReferencedMessage.Author.FullName" style="@referencedUserColorStyle">@referencedUserNick</span>
|
<span class="chatlog__reference-name" title="@Model.MessageGroup.ReferencedMessage.Author.FullName" style="@referencedUserColorStyle">@referencedUserNick</span>
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
@if (Model.MessageGroup.ReferencedMessage.EditedTimestamp != null)
|
@if (Model.MessageGroup.ReferencedMessage.EditedTimestamp is not null)
|
||||||
{
|
{
|
||||||
<span class="chatlog__reference-edited-timestamp" title="@FormatDate(Model.MessageGroup.ReferencedMessage.EditedTimestamp.Value)">(edited)</span>
|
<span class="chatlog__reference-edited-timestamp" title="@FormatDate(Model.MessageGroup.ReferencedMessage.EditedTimestamp.Value)">(edited)</span>
|
||||||
}
|
}
|
||||||
|
@ -98,13 +98,13 @@
|
||||||
var isPinnedStyle = message.IsPinned ? "chatlog__message--pinned" : null;
|
var isPinnedStyle = message.IsPinned ? "chatlog__message--pinned" : null;
|
||||||
|
|
||||||
<div class="chatlog__message @isPinnedStyle" data-message-id="@message.Id" id="message-@message.Id">
|
<div class="chatlog__message @isPinnedStyle" data-message-id="@message.Id" id="message-@message.Id">
|
||||||
@if (!string.IsNullOrWhiteSpace(message.Content) || message.EditedTimestamp != null)
|
@if (!string.IsNullOrWhiteSpace(message.Content) || message.EditedTimestamp is not null)
|
||||||
{
|
{
|
||||||
<div class="chatlog__content">
|
<div class="chatlog__content">
|
||||||
<div class="markdown">
|
<div class="markdown">
|
||||||
<span class="preserve-whitespace">@Raw(FormatMarkdown(message.Content))</span>
|
<span class="preserve-whitespace">@Raw(FormatMarkdown(message.Content))</span>
|
||||||
|
|
||||||
@if (message.EditedTimestamp != null)
|
@if (message.EditedTimestamp is not null)
|
||||||
{
|
{
|
||||||
<span class="chatlog__edited-timestamp" title="@FormatDate(message.EditedTimestamp.Value)">(edited)</span>
|
<span class="chatlog__edited-timestamp" title="@FormatDate(message.EditedTimestamp.Value)">(edited)</span>
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@
|
||||||
@foreach (var embed in message.Embeds)
|
@foreach (var embed in message.Embeds)
|
||||||
{
|
{
|
||||||
<div class="chatlog__embed">
|
<div class="chatlog__embed">
|
||||||
@if (embed.Color != null)
|
@if (embed.Color is not null)
|
||||||
{
|
{
|
||||||
var embedColorStyle = $"background-color: rgba({embed.Color?.R},{embed.Color?.G},{embed.Color?.B},{embed.Color?.A})";
|
var embedColorStyle = $"background-color: rgba({embed.Color?.R},{embed.Color?.G},{embed.Color?.B},{embed.Color?.A})";
|
||||||
<div class="chatlog__embed-color-pill" style="@embedColorStyle"></div>
|
<div class="chatlog__embed-color-pill" style="@embedColorStyle"></div>
|
||||||
|
@ -175,7 +175,7 @@
|
||||||
<div class="chatlog__embed-content-container">
|
<div class="chatlog__embed-content-container">
|
||||||
<div class="chatlog__embed-content">
|
<div class="chatlog__embed-content">
|
||||||
<div class="chatlog__embed-text">
|
<div class="chatlog__embed-text">
|
||||||
@if (embed.Author != null)
|
@if (embed.Author is not null)
|
||||||
{
|
{
|
||||||
<div class="chatlog__embed-author">
|
<div class="chatlog__embed-author">
|
||||||
@if (!string.IsNullOrWhiteSpace(embed.Author.IconUrl))
|
@if (!string.IsNullOrWhiteSpace(embed.Author.IconUrl))
|
||||||
|
@ -249,7 +249,7 @@
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (embed.Thumbnail != null)
|
@if (embed.Thumbnail is not null)
|
||||||
{
|
{
|
||||||
<div class="chatlog__embed-thumbnail-container">
|
<div class="chatlog__embed-thumbnail-container">
|
||||||
<a class="chatlog__embed-thumbnail-link" href="@await ResolveUrlAsync(embed.Thumbnail.Url)">
|
<a class="chatlog__embed-thumbnail-link" href="@await ResolveUrlAsync(embed.Thumbnail.Url)">
|
||||||
|
@ -259,7 +259,7 @@
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (embed.Image != null)
|
@if (embed.Image is not null)
|
||||||
{
|
{
|
||||||
<div class="chatlog__embed-image-container">
|
<div class="chatlog__embed-image-container">
|
||||||
<a class="chatlog__embed-image-link" href="@await ResolveUrlAsync(embed.Image.Url)">
|
<a class="chatlog__embed-image-link" href="@await ResolveUrlAsync(embed.Image.Url)">
|
||||||
|
@ -268,7 +268,7 @@
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (embed.Footer != null || embed.Timestamp != null)
|
@if (embed.Footer is not null || embed.Timestamp is not null)
|
||||||
{
|
{
|
||||||
<div class="chatlog__embed-footer">
|
<div class="chatlog__embed-footer">
|
||||||
@if (!string.IsNullOrWhiteSpace(embed.Footer?.IconUrl))
|
@if (!string.IsNullOrWhiteSpace(embed.Footer?.IconUrl))
|
||||||
|
@ -282,12 +282,12 @@
|
||||||
@embed.Footer.Text
|
@embed.Footer.Text
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (!string.IsNullOrWhiteSpace(embed.Footer?.Text) && embed.Timestamp != null)
|
@if (!string.IsNullOrWhiteSpace(embed.Footer?.Text) && embed.Timestamp is not null)
|
||||||
{
|
{
|
||||||
@(" • ")
|
@(" • ")
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (embed.Timestamp != null)
|
@if (embed.Timestamp is not null)
|
||||||
{
|
{
|
||||||
@FormatDate(embed.Timestamp.Value)
|
@FormatDate(embed.Timestamp.Value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,18 +78,18 @@
|
||||||
<div class="preamble__entry preamble__entry--small">@Model.ExportContext.Request.Channel.Topic</div>
|
<div class="preamble__entry preamble__entry--small">@Model.ExportContext.Request.Channel.Topic</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (Model.ExportContext.Request.After != null || Model.ExportContext.Request.Before != null)
|
@if (Model.ExportContext.Request.After is not null || Model.ExportContext.Request.Before is not null)
|
||||||
{
|
{
|
||||||
<div class="preamble__entry preamble__entry--small">
|
<div class="preamble__entry preamble__entry--small">
|
||||||
@if (Model.ExportContext.Request.After != null && Model.ExportContext.Request.Before != null)
|
@if (Model.ExportContext.Request.After is not null && Model.ExportContext.Request.Before is not null)
|
||||||
{
|
{
|
||||||
@($"Between {FormatDate(Model.ExportContext.Request.After.Value.ToDate())} and {FormatDate(Model.ExportContext.Request.Before.Value.ToDate())}")
|
@($"Between {FormatDate(Model.ExportContext.Request.After.Value.ToDate())} and {FormatDate(Model.ExportContext.Request.Before.Value.ToDate())}")
|
||||||
}
|
}
|
||||||
else if (Model.ExportContext.Request.After != null)
|
else if (Model.ExportContext.Request.After is not null)
|
||||||
{
|
{
|
||||||
@($"After {FormatDate(Model.ExportContext.Request.After.Value.ToDate())}")
|
@($"After {FormatDate(Model.ExportContext.Request.After.Value.ToDate())}")
|
||||||
}
|
}
|
||||||
else if (Model.ExportContext.Request.Before != null)
|
else if (Model.ExportContext.Request.Before is not null)
|
||||||
{
|
{
|
||||||
@($"Before {FormatDate(Model.ExportContext.Request.Before.Value.ToDate())}")
|
@($"Before {FormatDate(Model.ExportContext.Request.Before.Value.ToDate())}")
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,19 +118,19 @@ namespace DiscordChatExporter.Core.Exporting.Writers
|
||||||
_writer.WriteString("timestamp", embed.Timestamp);
|
_writer.WriteString("timestamp", embed.Timestamp);
|
||||||
_writer.WriteString("description", FormatMarkdown(embed.Description));
|
_writer.WriteString("description", FormatMarkdown(embed.Description));
|
||||||
|
|
||||||
if (embed.Color != null)
|
if (embed.Color is not null)
|
||||||
_writer.WriteString("color", embed.Color.Value.ToHex());
|
_writer.WriteString("color", embed.Color.Value.ToHex());
|
||||||
|
|
||||||
if (embed.Author != null)
|
if (embed.Author is not null)
|
||||||
await WriteEmbedAuthorAsync(embed.Author);
|
await WriteEmbedAuthorAsync(embed.Author);
|
||||||
|
|
||||||
if (embed.Thumbnail != null)
|
if (embed.Thumbnail is not null)
|
||||||
await WriteEmbedThumbnailAsync(embed.Thumbnail);
|
await WriteEmbedThumbnailAsync(embed.Thumbnail);
|
||||||
|
|
||||||
if (embed.Image != null)
|
if (embed.Image is not null)
|
||||||
await WriteEmbedImageAsync(embed.Image);
|
await WriteEmbedImageAsync(embed.Image);
|
||||||
|
|
||||||
if (embed.Footer != null)
|
if (embed.Footer is not null)
|
||||||
await WriteEmbedFooterAsync(embed.Footer);
|
await WriteEmbedFooterAsync(embed.Footer);
|
||||||
|
|
||||||
// Fields
|
// Fields
|
||||||
|
@ -266,7 +266,7 @@ namespace DiscordChatExporter.Core.Exporting.Writers
|
||||||
_writer.WriteEndArray();
|
_writer.WriteEndArray();
|
||||||
|
|
||||||
// Message reference
|
// Message reference
|
||||||
if (message.Reference != null)
|
if (message.Reference is not null)
|
||||||
{
|
{
|
||||||
_writer.WriteStartObject("reference");
|
_writer.WriteStartObject("reference");
|
||||||
_writer.WriteString("messageId", message.Reference.MessageId?.ToString());
|
_writer.WriteString("messageId", message.Reference.MessageId?.ToString());
|
||||||
|
|
|
@ -112,7 +112,7 @@ namespace DiscordChatExporter.Core.Exporting.Writers.MarkdownVisitors
|
||||||
var name = role?.Name ?? "deleted-role";
|
var name = role?.Name ?? "deleted-role";
|
||||||
var color = role?.Color;
|
var color = role?.Color;
|
||||||
|
|
||||||
var style = color != null
|
var style = color is not null
|
||||||
? $"color: rgb({color?.R}, {color?.G}, {color?.B}); background-color: rgba({color?.R}, {color?.G}, {color?.B}, 0.1);"
|
? $"color: rgb({color?.R}, {color?.G}, {color?.B}); background-color: rgba({color?.R}, {color?.G}, {color?.B}, 0.1);"
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
|
|
|
@ -118,10 +118,10 @@ namespace DiscordChatExporter.Core.Exporting.Writers
|
||||||
if (!string.IsNullOrWhiteSpace(Context.Request.Channel.Topic))
|
if (!string.IsNullOrWhiteSpace(Context.Request.Channel.Topic))
|
||||||
await _writer.WriteLineAsync($"Topic: {Context.Request.Channel.Topic}");
|
await _writer.WriteLineAsync($"Topic: {Context.Request.Channel.Topic}");
|
||||||
|
|
||||||
if (Context.Request.After != null)
|
if (Context.Request.After is not null)
|
||||||
await _writer.WriteLineAsync($"After: {Context.FormatDate(Context.Request.After.Value.ToDate())}");
|
await _writer.WriteLineAsync($"After: {Context.FormatDate(Context.Request.After.Value.ToDate())}");
|
||||||
|
|
||||||
if (Context.Request.Before != 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('='.Repeat(62));
|
||||||
|
|
|
@ -27,11 +27,11 @@ namespace DiscordChatExporter.Core.Markdown.Matching
|
||||||
var match = matcher.TryMatch(stringPart);
|
var match = matcher.TryMatch(stringPart);
|
||||||
|
|
||||||
// If there's no match - continue
|
// If there's no match - continue
|
||||||
if (match == null)
|
if (match is null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If this match is earlier than previous earliest - replace
|
// If this match is earlier than previous earliest - replace
|
||||||
if (earliestMatch == null || match.StringPart.StartIndex < earliestMatch.StringPart.StartIndex)
|
if (earliestMatch is null || match.StringPart.StartIndex < earliestMatch.StringPart.StartIndex)
|
||||||
earliestMatch = match;
|
earliestMatch = match;
|
||||||
|
|
||||||
// If the earliest match starts at the very beginning - break,
|
// If the earliest match starts at the very beginning - break,
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace DiscordChatExporter.Core.Markdown.Matching
|
||||||
var match = matcher.TryMatch(stringPart.Slice(currentIndex, stringPart.EndIndex - currentIndex));
|
var match = matcher.TryMatch(stringPart.Slice(currentIndex, stringPart.EndIndex - currentIndex));
|
||||||
|
|
||||||
// If there's no match - break
|
// If there's no match - break
|
||||||
if (match == null)
|
if (match is null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// If this match doesn't start immediately at current index - transform and yield fallback first
|
// If this match doesn't start immediately at current index - transform and yield fallback first
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace DiscordChatExporter.Core.Utils
|
||||||
if (i > 3)
|
if (i > 3)
|
||||||
{
|
{
|
||||||
var retryAfterDelay = result.Result.Headers.RetryAfter.Delta;
|
var retryAfterDelay = result.Result.Headers.RetryAfter.Delta;
|
||||||
if (retryAfterDelay != null)
|
if (retryAfterDelay is not null)
|
||||||
return retryAfterDelay.Value + TimeSpan.FromSeconds(1); // margin just in case
|
return retryAfterDelay.Value + TimeSpan.FromSeconds(1); // margin just in case
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace DiscordChatExporter.Gui.Behaviors
|
||||||
var behavior = (MultiSelectionListBoxBehavior<T>) sender;
|
var behavior = (MultiSelectionListBoxBehavior<T>) sender;
|
||||||
if (behavior._modelHandled) return;
|
if (behavior._modelHandled) return;
|
||||||
|
|
||||||
if (behavior.AssociatedObject == null)
|
if (behavior.AssociatedObject is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
behavior._modelHandled = true;
|
behavior._modelHandled = true;
|
||||||
|
@ -43,7 +43,7 @@ namespace DiscordChatExporter.Gui.Behaviors
|
||||||
_viewHandled = true;
|
_viewHandled = true;
|
||||||
|
|
||||||
AssociatedObject.SelectedItems.Clear();
|
AssociatedObject.SelectedItems.Clear();
|
||||||
if (SelectedItems != null)
|
if (SelectedItems is not null)
|
||||||
{
|
{
|
||||||
foreach (var item in SelectedItems)
|
foreach (var item in SelectedItems)
|
||||||
AssociatedObject.SelectedItems.Add(item);
|
AssociatedObject.SelectedItems.Add(item);
|
||||||
|
@ -56,7 +56,7 @@ namespace DiscordChatExporter.Gui.Behaviors
|
||||||
private void OnListBoxSelectionChanged(object sender, SelectionChangedEventArgs args)
|
private void OnListBoxSelectionChanged(object sender, SelectionChangedEventArgs args)
|
||||||
{
|
{
|
||||||
if (_viewHandled) return;
|
if (_viewHandled) return;
|
||||||
if (AssociatedObject.Items.SourceCollection == null) return;
|
if (AssociatedObject.Items.SourceCollection is null) return;
|
||||||
|
|
||||||
SelectedItems = AssociatedObject.SelectedItems.Cast<T>().ToArray();
|
SelectedItems = AssociatedObject.SelectedItems.Cast<T>().ToArray();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ namespace DiscordChatExporter.Gui.Behaviors
|
||||||
private void OnListBoxItemsChanged(object sender, NotifyCollectionChangedEventArgs args)
|
private void OnListBoxItemsChanged(object sender, NotifyCollectionChangedEventArgs args)
|
||||||
{
|
{
|
||||||
if (_viewHandled) return;
|
if (_viewHandled) return;
|
||||||
if (AssociatedObject.Items.SourceCollection == null) return;
|
if (AssociatedObject.Items.SourceCollection is null) return;
|
||||||
SelectItems();
|
SelectItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ namespace DiscordChatExporter.Gui.Behaviors
|
||||||
{
|
{
|
||||||
base.OnDetaching();
|
base.OnDetaching();
|
||||||
|
|
||||||
if (AssociatedObject != null)
|
if (AssociatedObject is not null)
|
||||||
{
|
{
|
||||||
AssociatedObject.SelectionChanged -= OnListBoxSelectionChanged;
|
AssociatedObject.SelectionChanged -= OnListBoxSelectionChanged;
|
||||||
((INotifyCollectionChanged) AssociatedObject.Items).CollectionChanged -= OnListBoxItemsChanged;
|
((INotifyCollectionChanged) AssociatedObject.Items).CollectionChanged -= OnListBoxItemsChanged;
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace DiscordChatExporter.Gui.Services
|
||||||
if (!_settingsService.IsAutoUpdateEnabled)
|
if (!_settingsService.IsAutoUpdateEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_updateVersion == null || !_updatePrepared || _updaterLaunched)
|
if (_updateVersion is null || !_updatePrepared || _updaterLaunched)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace DiscordChatExporter.Gui.ViewModels.Dialogs
|
||||||
|
|
||||||
public IReadOnlyList<Channel>? Channels { get; set; }
|
public IReadOnlyList<Channel>? Channels { get; set; }
|
||||||
|
|
||||||
public bool IsSingleChannel => Channels == null || Channels.Count == 1;
|
public bool IsSingleChannel => Channels is null || Channels.Count == 1;
|
||||||
|
|
||||||
public string? OutputPath { get; set; }
|
public string? OutputPath { get; set; }
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ namespace DiscordChatExporter.Gui.ViewModels.Dialogs
|
||||||
|
|
||||||
public DateTimeOffset? AfterDate { get; set; }
|
public DateTimeOffset? AfterDate { get; set; }
|
||||||
|
|
||||||
public bool IsAfterDateSet => AfterDate != null;
|
public bool IsAfterDateSet => AfterDate is not null;
|
||||||
|
|
||||||
public TimeSpan? AfterTime { get; set; }
|
public TimeSpan? AfterTime { get; set; }
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ namespace DiscordChatExporter.Gui.ViewModels.Dialogs
|
||||||
|
|
||||||
public DateTimeOffset? BeforeDate { get; set; }
|
public DateTimeOffset? BeforeDate { get; set; }
|
||||||
|
|
||||||
public bool IsBeforeDateSet => BeforeDate != null;
|
public bool IsBeforeDateSet => BeforeDate is not null;
|
||||||
|
|
||||||
public TimeSpan? BeforeTime { get; set; }
|
public TimeSpan? BeforeTime { get; set; }
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ namespace DiscordChatExporter.Gui.ViewModels.Dialogs
|
||||||
_settingsService.LastShouldDownloadMedia = ShouldDownloadMedia;
|
_settingsService.LastShouldDownloadMedia = ShouldDownloadMedia;
|
||||||
|
|
||||||
// If single channel - prompt file path
|
// If single channel - prompt file path
|
||||||
if (Channels != null && IsSingleChannel)
|
if (Channels is not null && IsSingleChannel)
|
||||||
{
|
{
|
||||||
var channel = Channels.Single();
|
var channel = Channels.Single();
|
||||||
var defaultFileName = ExportRequest.GetDefaultOutputFileName(
|
var defaultFileName = ExportRequest.GetDefaultOutputFileName(
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||||
|
|
||||||
public Guild? SelectedGuild { get; set; }
|
public Guild? SelectedGuild { get; set; }
|
||||||
|
|
||||||
public IReadOnlyList<Channel>? AvailableChannels => SelectedGuild != null
|
public IReadOnlyList<Channel>? AvailableChannels => SelectedGuild is not null
|
||||||
? GuildChannelMap?[SelectedGuild]
|
? GuildChannelMap?[SelectedGuild]
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var updateVersion = await _updateService.CheckForUpdatesAsync();
|
var updateVersion = await _updateService.CheckForUpdatesAsync();
|
||||||
if (updateVersion == null)
|
if (updateVersion is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Notifications.Enqueue($"Downloading update to {App.Name} v{updateVersion}...");
|
Notifications.Enqueue($"Downloading update to {App.Name} v{updateVersion}...");
|
||||||
|
@ -111,7 +111,7 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||||
|
|
||||||
_settingsService.Load();
|
_settingsService.Load();
|
||||||
|
|
||||||
if (_settingsService.LastToken != null)
|
if (_settingsService.LastToken is not null)
|
||||||
{
|
{
|
||||||
IsBotToken = _settingsService.LastToken.Type == AuthTokenType.Bot;
|
IsBotToken = _settingsService.LastToken.Type == AuthTokenType.Bot;
|
||||||
TokenValue = _settingsService.LastToken.Value;
|
TokenValue = _settingsService.LastToken.Value;
|
||||||
|
@ -183,12 +183,12 @@ namespace DiscordChatExporter.Gui.ViewModels
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanExportChannels =>
|
public bool CanExportChannels =>
|
||||||
!IsBusy && SelectedGuild != null && SelectedChannels != null && SelectedChannels.Any();
|
!IsBusy && SelectedGuild is not null && SelectedChannels is not null && SelectedChannels.Any();
|
||||||
|
|
||||||
public async void ExportChannels()
|
public async void ExportChannels()
|
||||||
{
|
{
|
||||||
var token = _settingsService.LastToken;
|
var token = _settingsService.LastToken;
|
||||||
if (token == null || SelectedGuild == null || SelectedChannels == null || !SelectedChannels.Any())
|
if (token is null || SelectedGuild is null || SelectedChannels is null || !SelectedChannels.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var dialog = _viewModelFactory.CreateExportSetupViewModel(SelectedGuild, SelectedChannels);
|
var dialog = _viewModelFactory.CreateExportSetupViewModel(SelectedGuild, SelectedChannels);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue