feat: replace LiteDB with Sqlite
- Replace LiteDB database engine with Sqlite Note: old databases will not be deleted - Message duplication detection improvements - Tolerate parse errors in release builds, log them
This commit is contained in:
+37
-20
@@ -1,15 +1,22 @@
|
||||
using ChatTwo.Code;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using LiteDB;
|
||||
using MessagePack;
|
||||
|
||||
namespace ChatTwo;
|
||||
|
||||
internal abstract class Chunk {
|
||||
[BsonIgnore]
|
||||
[Union(0, typeof(TextChunk))]
|
||||
[Union(1, typeof(IconChunk))]
|
||||
[MessagePackObject]
|
||||
public abstract class Chunk {
|
||||
[IgnoreMember]
|
||||
internal Message? Message { get; set; }
|
||||
|
||||
internal ChunkSource Source { get; set; }
|
||||
internal Payload? Link { get; set; }
|
||||
[Key(0)]
|
||||
public ChunkSource Source { get; set; }
|
||||
|
||||
[Key(1)]
|
||||
[MessagePackFormatter(typeof(PayloadMessagePackFormatter))]
|
||||
public Payload? Link { get; set; }
|
||||
|
||||
protected Chunk(ChunkSource source, Payload? link) {
|
||||
Source = source;
|
||||
@@ -38,27 +45,38 @@ internal abstract class Chunk {
|
||||
}
|
||||
}
|
||||
|
||||
internal enum ChunkSource {
|
||||
public enum ChunkSource {
|
||||
None,
|
||||
Sender,
|
||||
Content,
|
||||
}
|
||||
|
||||
internal class TextChunk : Chunk {
|
||||
internal ChatType? FallbackColour { get; set; }
|
||||
internal uint? Foreground { get; set; }
|
||||
internal uint? Glow { get; set; }
|
||||
internal bool Italic { get; set; }
|
||||
internal string Content { get; set; }
|
||||
[MessagePackObject]
|
||||
public class TextChunk : Chunk {
|
||||
[Key(2)]
|
||||
public ChatType? FallbackColour { get; set; }
|
||||
[Key(3)]
|
||||
public uint? Foreground { get; set; }
|
||||
[Key(4)]
|
||||
public uint? Glow { get; set; }
|
||||
[Key(5)]
|
||||
public bool Italic { get; set; }
|
||||
[Key(6)]
|
||||
public string Content { get; set; }
|
||||
|
||||
internal TextChunk(ChunkSource source, Payload? link, string content) : base(source, link) {
|
||||
Content = content;
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618
|
||||
public TextChunk() : base(ChunkSource.None, null) {
|
||||
// ReSharper disable once UnusedMember.Global // Used by MessagePack
|
||||
public TextChunk(ChunkSource source, Payload? link, ChatType? fallbackColour, uint? foreground, uint? glow,
|
||||
bool italic, string content) : base(source, link) {
|
||||
FallbackColour = fallbackColour;
|
||||
Foreground = foreground;
|
||||
Glow = glow;
|
||||
Italic = italic;
|
||||
Content = content;
|
||||
}
|
||||
#pragma warning restore CS8618
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new TextChunk with identical styling to this one.
|
||||
@@ -74,13 +92,12 @@ internal class TextChunk : Chunk {
|
||||
}
|
||||
}
|
||||
|
||||
internal class IconChunk : Chunk {
|
||||
internal BitmapFontIcon Icon { get; set; }
|
||||
[MessagePackObject]
|
||||
public class IconChunk : Chunk {
|
||||
[Key(2)]
|
||||
public BitmapFontIcon Icon { get; set; }
|
||||
|
||||
public IconChunk(ChunkSource source, Payload? link, BitmapFontIcon icon) : base(source, link) {
|
||||
Icon = icon;
|
||||
}
|
||||
|
||||
public IconChunk() : base(ChunkSource.None, null) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user