diff --git a/ChatTwo/ChatTwo.csproj b/ChatTwo/ChatTwo.csproj index 5431a04..c2f8c25 100755 --- a/ChatTwo/ChatTwo.csproj +++ b/ChatTwo/ChatTwo.csproj @@ -1,6 +1,6 @@ - 1.29.16 + 1.29.17 net8.0-windows enable enable diff --git a/ChatTwo/Code/InputChannelExt.cs b/ChatTwo/Code/InputChannelExt.cs index 0f69560..00f32fe 100755 --- a/ChatTwo/Code/InputChannelExt.cs +++ b/ChatTwo/Code/InputChannelExt.cs @@ -109,7 +109,7 @@ internal static class InputChannelExt InputChannel.ExtraChatLinkshell7 => "/ecl7", InputChannel.ExtraChatLinkshell8 => "/ecl8", InputChannel.Invalid => "/e", - _ => "", + _ => "/e", }; public static IEnumerable? TextCommands(this InputChannel channel, IDataManager data) diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index 79d9123..ce33018 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -460,6 +460,13 @@ internal class UsedChannel TempTellTarget = null; TempChannel = InputChannel.Invalid; } + + internal void SetChannel(InputChannel channel) + { + UseTempChannel = false; + TempTellTarget = null; + Channel = channel; + } } [Serializable] diff --git a/ChatTwo/MessageStore.cs b/ChatTwo/MessageStore.cs index 8be63aa..c5222d3 100644 --- a/ChatTwo/MessageStore.cs +++ b/ChatTwo/MessageStore.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Data.Common; using ChatTwo.Code; +using ChatTwo.Ui; using ChatTwo.Util; using Dalamud.Game.Text.SeStringHandling; using MessagePack; @@ -444,7 +445,7 @@ internal class MessageStore : IDisposable ExtraChatChannel FROM messages " + whereClause + @" - LIMIT $Offset, 500; + LIMIT $Offset, $OffsetCount; "; cmd.CommandTimeout = 120; // this could take a while on slow computers @@ -453,7 +454,8 @@ internal class MessageStore : IDisposable cmd.Parameters.AddWithValue("$After", ((DateTimeOffset) after).ToUnixTimeMilliseconds()); cmd.Parameters.AddWithValue("$Before", ((DateTimeOffset) before).ToUnixTimeMilliseconds()); - cmd.Parameters.AddWithValue("$Offset", 500 * page); + cmd.Parameters.AddWithValue("$Offset", DbViewer.RowPerPage * page); + cmd.Parameters.AddWithValue("OffsetCount", DbViewer.RowPerPage); return new MessageEnumerator(cmd.ExecuteReader()); } diff --git a/ChatTwo/Ui/ChatLogWindow.cs b/ChatTwo/Ui/ChatLogWindow.cs index 1ea75e8..7dca733 100644 --- a/ChatTwo/Ui/ChatLogWindow.cs +++ b/ChatTwo/Ui/ChatLogWindow.cs @@ -505,9 +505,9 @@ public sealed class ChatLogWindow : Window AddPopOutsToDraw(); DrawAutoComplete(); } - catch (Exception e) + catch (Exception ex) { - Plugin.Log.Error($"Error drawing Chat Log window: {e}"); + Plugin.Log.Error(ex, "Error drawing Chat Log window"); // Prevent recurring draw failures from constantly trying to grab // input focus, which breaks every other ImGui window. Activate = false; @@ -540,6 +540,11 @@ public sealed class ChatLogWindow : Window DrawTabBar(); var activeTab = Plugin.CurrentTab; + + // This tab has a fixed channel, so we force this channel to be always set as current + if (activeTab.Channel is not null) + activeTab.CurrentChannel.SetChannel(activeTab.Channel.Value); + if (Plugin.Config.PreviewPosition is PreviewPosition.Inside && Plugin.InputPreview.IsDrawable) Plugin.InputPreview.DrawPreview(); @@ -793,15 +798,14 @@ public sealed class ChatLogWindow : Window channelNameChunks = [new TextChunk(ChunkSource.None, null, name)]; } } - else if (activeTab.CurrentChannel.TellTarget != null && activeTab.CurrentChannel.TellTarget.IsSet()) + else if (activeTab.CurrentChannel.TellTarget?.IsSet() == true) { channelNameChunks = GenerateTellTargetName(activeTab.CurrentChannel.TellTarget); } else if (activeTab is { Channel: { } channel }) { // We cannot lookup ExtraChat channel names from index over - // IPC so we just don't show the name if it's the tabs - // channel. + // IPC so we just don't show the name if it's the tabs channel. // // We don't call channel.ToChatType().Name() as it has the // long name as used in the settings window. @@ -809,7 +813,12 @@ public sealed class ChatLogWindow : Window } else if (Plugin.ExtraChat.ChannelOverride is var (overrideName, _)) { - channelNameChunks = [new TextChunk(ChunkSource.None, null, overrideName)]; + // If the current channel is not an ExtraChat Linkshell add a warning for the user + var warning = new TextChunk(ChunkSource.None, null, activeTab.CurrentChannel.Channel.IsExtraChatLinkshell() + ? "" + : $"(Warning: {activeTab.CurrentChannel.Channel.ToChatType().Name()})"); + + channelNameChunks = [new TextChunk(ChunkSource.None, null, overrideName), warning]; } else if (ScreenshotMode && activeTab.CurrentChannel.Channel is InputChannel.Tell && activeTab.CurrentChannel.TellTarget != null) { diff --git a/ChatTwo/Ui/DbViewer.cs b/ChatTwo/Ui/DbViewer.cs index 93c7359..b7e03d4 100644 --- a/ChatTwo/Ui/DbViewer.cs +++ b/ChatTwo/Ui/DbViewer.cs @@ -15,6 +15,8 @@ namespace ChatTwo.Ui; public class DbViewer : Window { + public const float RowPerPage = 1000.0f; + private readonly Plugin Plugin; private static readonly DateTime MinimalDate = new(2021, 1, 1); @@ -73,7 +75,7 @@ public class DbViewer : Window public override void Draw() { - var totalPages = (int)Math.Ceiling(Count / 500.0f); + var totalPages = (int)Math.Ceiling(Count / RowPerPage); if (totalPages < 1) totalPages = 1; @@ -236,7 +238,7 @@ public class DbViewer : Window { if (SimpleSearchTerm == "") { - Filtered = new ConcurrentStack(Messages.Reverse()); + Filtered = new ConcurrentStack(Messages.Reverse().OrderByDescending(m => m.Date)); return; } @@ -244,7 +246,7 @@ public class DbViewer : Window Messages.Reverse().Where(m => ChunkUtil.ToRawString(m.Sender).Contains(SimpleSearchTerm, StringComparison.InvariantCultureIgnoreCase) || ChunkUtil.ToRawString(m.Content).Contains(SimpleSearchTerm, StringComparison.InvariantCultureIgnoreCase) - )); + ).OrderByDescending(m => m.Date)); } private void DateRefresh()