Merge pull request #150

* Hash message links so messages with different links aren't considered…

* Add option to toggle if links should be considered for the message ha…
This commit is contained in:
Simon Schürrle
2025-06-22 20:17:19 +02:00
committed by GitHub
parent 34c4d87a33
commit 0d075ca060
6 changed files with 51 additions and 4 deletions
+2
View File
@@ -73,6 +73,7 @@ internal class Configuration : IPluginConfiguration
public bool FilterIncludePreviousSessions;
public bool SortAutoTranslate;
public bool CollapseDuplicateMessages;
public bool CollapseKeepUniqueLinks;
public bool PlaySounds = true;
public bool KeepInputFocus = true;
public int MaxLinesToRender = 10_000; // 1-10000
@@ -163,6 +164,7 @@ internal class Configuration : IPluginConfiguration
FilterIncludePreviousSessions = other.FilterIncludePreviousSessions;
SortAutoTranslate = other.SortAutoTranslate;
CollapseDuplicateMessages = other.CollapseDuplicateMessages;
CollapseKeepUniqueLinks = other.CollapseKeepUniqueLinks;
PlaySounds = other.PlaySounds;
KeepInputFocus = other.KeepInputFocus;
MaxLinesToRender = other.MaxLinesToRender;
+13 -4
View File
@@ -137,10 +137,19 @@ internal partial class Message
private int GenerateHash()
{
return SortCode.GetHashCode()
^ ExtraChatChannel.GetHashCode()
^ string.Join("", Sender.Select(c => c.StringValue())).GetHashCode()
^ string.Join("", Content.Select(c => c.StringValue())).GetHashCode();
var hash = SortCode.GetHashCode()
^ ExtraChatChannel.GetHashCode()
^ string.Join("", Sender.Select(c => c.StringValue())).GetHashCode()
^ string.Join("", Content.Select(c => c.StringValue())).GetHashCode();
if (Plugin.Config.CollapseKeepUniqueLinks)
{
// Hash the link too for something like DeathRecap where the message is the same
// but the link is different
hash ^= string.Join("", Content.Select(c => c.Link?.GetHashCode())).GetHashCode();
}
return hash;
}
private static Guid ExtractExtraChatChannel(SeString contentSource)
+19
View File
@@ -2075,6 +2075,24 @@ namespace ChatTwo.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Don't collapse messages if they link to different things with the same text.
/// </summary>
internal static string Options_CollapseDuplicateMsgUniqueLink_Description {
get {
return ResourceManager.GetString("Options_CollapseDuplicateMsgUniqueLink_Description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Keep unique links seperate
/// </summary>
internal static string Options_CollapseDuplicateMsgUniqueLink_Name {
get {
return ResourceManager.GetString("Options_CollapseDuplicateMsgUniqueLink_Name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The side of {0} to display help for commands on..
/// </summary>
@@ -3867,3 +3885,4 @@ namespace ChatTwo.Resources {
}
}
}
+6
View File
@@ -950,6 +950,12 @@ Sie wurden gewarnt.</value>
<data name="Options_CollapseDuplicateMessages_Description">
<value>Ersetzt sich wiederholende Nachrichten mit einem Zähler, der der originalen Nachricht angehängt wird.</value>
</data>
<data name="Options_CollapseDuplicateMsgUniqueLink_Name">
<value>Trenne seperate Verlinkungen</value>
</data>
<data name="Options_CollapseDuplicateMsgUniqueLink_Description">
<value>Trenne Nachrichten die den gleichen text mit verschieden Verlinkungen haben.</value>
</data>
<data name="Options_Tabs_ExtraChatChannels">
<value>ExtraChat-Kanäle</value>
</data>
+6
View File
@@ -961,6 +961,12 @@
<data name="Options_CollapseDuplicateMessages_Description">
<value>Replace consecutive duplicate messages with a counter appended to the first instance of the message.</value>
</data>
<data name="Options_CollapseDuplicateMsgUniqueLink_Name">
<value>Keep unique links seperate</value>
</data>
<data name="Options_CollapseDuplicateMsgUniqueLink_Description">
<value>Don't collapse messages if they link to different things with the same text.</value>
</data>
<data name="Options_Tabs_ExtraChatChannels">
<value>ExtraChat channels</value>
</data>
+5
View File
@@ -109,6 +109,11 @@ internal sealed class Display : ISettingsTab
ImGui.Spacing();
ImGuiUtil.OptionCheckbox(ref Mutable.CollapseDuplicateMessages, Language.Options_CollapseDuplicateMessages_Name, Language.Options_CollapseDuplicateMessages_Description);
if (Mutable.CollapseDuplicateMessages)
{
using var _ = ImRaii.PushIndent();
ImGuiUtil.OptionCheckbox(ref Mutable.CollapseKeepUniqueLinks, Language.Options_CollapseDuplicateMsgUniqueLink_Name, Language.Options_CollapseDuplicateMsgUniqueLink_Description);
}
ImGui.Spacing();
}
}