From f9a800e667687c3f8ffd9110dd21fe80adf2e921 Mon Sep 17 00:00:00 2001 From: "Jacob P." Date: Fri, 19 Jun 2026 01:37:00 +0200 Subject: [PATCH] Add comments --- DiscordChatExporter.Core/Exporting/ChannelExporter.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DiscordChatExporter.Core/Exporting/ChannelExporter.cs b/DiscordChatExporter.Core/Exporting/ChannelExporter.cs index 5af52480..00ae2476 100644 --- a/DiscordChatExporter.Core/Exporting/ChannelExporter.cs +++ b/DiscordChatExporter.Core/Exporting/ChannelExporter.cs @@ -113,9 +113,11 @@ public class ChannelExporter(DiscordClient discord) [EnumeratorCancellation] CancellationToken innerCancellationToken ) { + // If the message order is not reversed, the starter message should be the first one in the output, so we yield it before fetching the rest of the thread's history. if (starterMessage is not null && !request.IsReverseMessageOrder) yield return starterMessage; + // Fetch the rest of the thread's history and yield messages one by one await foreach (var message in messages.WithCancellation(innerCancellationToken)) { // Avoid exporting the starter message twice in case it's also returned as part @@ -124,6 +126,7 @@ public class ChannelExporter(DiscordClient discord) yield return message; } + // If the message order is reversed, the starter message should be the last one in the output, so we yield it after fetching the rest of the thread's history. if (starterMessage is not null && request.IsReverseMessageOrder) yield return starterMessage; }