mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-09-17 16:24:47 +02:00
Compare commits
3 Commits
v44.0
...
ae64747ce4
Author | SHA1 | Date | |
---|---|---|---|
ae64747ce4
|
|||
60761d80ab
|
|||
e11db62015
|
@@ -15,14 +15,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.0.11" />
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.11" />
|
||||
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.0.11" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.11" />
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.11" Condition=" '$(Configuration)' == 'Debug' " />
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.11" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.11" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.11" />
|
||||
<PackageReference Include="Avalonia" Version="11.2.3" />
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.2.3" />
|
||||
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.1.5" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.2.3" />
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.2.3" Condition=" '$(Configuration)' == 'Debug' " />
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.3" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.2.3" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="999.0.0-build.0.g0d941a6a62" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@@ -16,6 +16,10 @@
|
||||
<Setter Property="FontFamily" Value="Consolas,Courier" />
|
||||
<Setter Property="FontSize" Value="15" />
|
||||
</Style>
|
||||
<Style Selector="Label">
|
||||
<Setter Property="Margin" Value="0 5" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
</Style>
|
||||
<Style Selector="WrapPanel > StackPanel">
|
||||
<Setter Property="Orientation" Value="Vertical" />
|
||||
<Setter Property="Margin" Value="0 0 10 10" />
|
||||
|
@@ -16,6 +16,10 @@
|
||||
<Setter Property="FontFamily" Value="Consolas,Courier" />
|
||||
<Setter Property="FontSize" Value="15" />
|
||||
</Style>
|
||||
<Style Selector="Label">
|
||||
<Setter Property="Margin" Value="0 5" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
</Style>
|
||||
<Style Selector="WrapPanel > StackPanel">
|
||||
<Setter Property="Orientation" Value="Vertical" />
|
||||
<Setter Property="Margin" Value="0 0 10 10" />
|
||||
|
@@ -13,13 +13,21 @@
|
||||
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock TextWrapping="Wrap">
|
||||
To start tracking messages, copy the tracking script and paste it into the console of either the Discord app, or your browser. The console is usually opened by pressing Ctrl+Shift+I.
|
||||
<TextBlock.Text>
|
||||
<MultiBinding StringFormat="To start tracking messages, copy the tracking script and paste it into the console of either the Discord app, or your browser. The console is usually opened by pressing {0}.">
|
||||
<Binding Path="OpenDevToolsShortcutText" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal" Spacing="10">
|
||||
<Button x:Name="CopyTrackingScript" Click="CopyTrackingScriptButton_OnClick" IsEnabled="{Binding IsCopyTrackingScriptButtonEnabled}">Copy Tracking Script</Button>
|
||||
</StackPanel>
|
||||
<TextBlock TextWrapping="Wrap" Margin="0 5 0 0">
|
||||
By default, the Discord app does not allow opening the console. The button below will change a hidden setting in the Discord app that controls whether the Ctrl+Shift+I shortcut is enabled.
|
||||
<TextBlock.Text>
|
||||
<MultiBinding StringFormat="By default, the Discord app does not allow opening the console. The button below will change a hidden setting in the Discord app that controls whether the {0} shortcut is enabled.">
|
||||
<Binding Path="OpenDevToolsShortcutText" />
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
<Button DockPanel.Dock="Right" Command="{Binding OnClickToggleAppDevTools}" Content="{Binding ToggleAppDevToolsButtonText}" IsEnabled="{Binding IsToggleAppDevToolsButtonEnabled}" />
|
||||
</StackPanel>
|
||||
|
@@ -23,6 +23,8 @@ sealed partial class TrackingPageModel : ObservableObject {
|
||||
[NotifyPropertyChangedFor(nameof(ToggleAppDevToolsButtonText))]
|
||||
private bool isToggleAppDevToolsButtonEnabled = false;
|
||||
|
||||
public string OpenDevToolsShortcutText { get; } = OperatingSystem.IsMacOS() ? "Cmd+Shift+I" : "Ctrl+Shift+I";
|
||||
|
||||
public string ToggleAppDevToolsButtonText {
|
||||
get {
|
||||
if (!AreDevToolsEnabled.HasValue) {
|
||||
@@ -33,7 +35,7 @@ sealed partial class TrackingPageModel : ObservableObject {
|
||||
return "Unavailable";
|
||||
}
|
||||
|
||||
return AreDevToolsEnabled.Value ? "Disable Ctrl+Shift+I" : "Enable Ctrl+Shift+I";
|
||||
return (AreDevToolsEnabled.Value ? "Disable" : "Enable") + " " + OpenDevToolsShortcutText;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,11 +104,11 @@ sealed partial class TrackingPageModel : ObservableObject {
|
||||
switch (await DiscordAppSettings.ConfigureDevTools(newState)) {
|
||||
case SettingsJsonResult.Success:
|
||||
AreDevToolsEnabled = newState;
|
||||
await Dialog.ShowOk(window, DialogTitle, "Ctrl+Shift+I was " + (newState ? "enabled." : "disabled.") + " Restart the Discord app for the change to take effect.");
|
||||
await Dialog.ShowOk(window, DialogTitle, OpenDevToolsShortcutText + " was " + (newState ? "enabled." : "disabled.") + " Restart the Discord app for the change to take effect.");
|
||||
break;
|
||||
|
||||
case SettingsJsonResult.AlreadySet:
|
||||
await Dialog.ShowOk(window, DialogTitle, "Ctrl+Shift+I is already " + (newState ? "enabled." : "disabled."));
|
||||
await Dialog.ShowOk(window, DialogTitle, OpenDevToolsShortcutText + " is already " + (newState ? "enabled." : "disabled."));
|
||||
AreDevToolsEnabled = newState;
|
||||
break;
|
||||
|
||||
|
@@ -40,13 +40,13 @@
|
||||
<Style Selector="TabItem:pointerover /template/ Border">
|
||||
<Setter Property="Background" Value="#455785" />
|
||||
</Style>
|
||||
<Style Selector="TabItem:pointerover > TextBlock">
|
||||
<Style Selector="TabItem:pointerover /template/ ContentPresenter">
|
||||
<Setter Property="Foreground" Value="#E9E9E9" />
|
||||
</Style>
|
||||
<Style Selector="TabItem:selected:pointerover /template/ Border">
|
||||
<Setter Property="Background" Value="#FFFFFF" />
|
||||
</Style>
|
||||
<Style Selector="TabItem:selected:pointerover > TextBlock">
|
||||
<Style Selector="TabItem:selected:pointerover /template/ ContentPresenter">
|
||||
<Setter Property="Foreground" Value="#1A2234" />
|
||||
</Style>
|
||||
<Style Selector="TabItem:selected">
|
||||
@@ -56,9 +56,11 @@
|
||||
<Style Selector="TabItem:selected /template/ Border#PART_SelectedPipe">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
<Style Selector="TabItem:disabled > TextBlock">
|
||||
<Style Selector="TabItem:disabled /template/ ContentPresenter">
|
||||
<Setter Property="Foreground" Value="#B2B2B2" />
|
||||
<Setter Property="TextDecorations" Value="Strikethrough" />
|
||||
</Style>
|
||||
<Style Selector="TabItem:disabled /template/ ContentPresenter">
|
||||
<Setter Property="AccessText.TextDecorations" Value="Strikethrough" />
|
||||
</Style>
|
||||
<Style Selector="TabItem.first">
|
||||
<Setter Property="Margin" Value="0 13 0 0" />
|
||||
|
67
app/Server/Database/Sqlite/Schema/SqliteSchemaUpgradeTo10.cs
Normal file
67
app/Server/Database/Sqlite/Schema/SqliteSchemaUpgradeTo10.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Threading.Tasks;
|
||||
using DHT.Server.Database.Sqlite.Utils;
|
||||
|
||||
namespace DHT.Server.Database.Sqlite.Schema;
|
||||
|
||||
sealed class SqliteSchemaUpgradeTo10 : ISchemaUpgrade {
|
||||
async Task ISchemaUpgrade.Run(ISqliteConnection conn, ISchemaUpgradeCallbacks.IProgressReporter reporter) {
|
||||
await reporter.MainWork("Migrating message embeds...", 0, 5);
|
||||
await conn.ExecuteAsync("""
|
||||
CREATE TABLE message_embeds_new (
|
||||
message_id INTEGER NOT NULL,
|
||||
json TEXT NOT NULL,
|
||||
FOREIGN KEY (message_id) REFERENCES messages (message_id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
)
|
||||
""");
|
||||
await conn.ExecuteAsync("INSERT INTO message_embeds_new (message_id, json) SELECT message_id, json FROM message_embeds WHERE message_id IN (SELECT DISTINCT message_id FROM messages)");
|
||||
|
||||
await reporter.MainWork("Migrating message reactions...", 1, 5);
|
||||
await conn.ExecuteAsync("""
|
||||
CREATE TABLE message_reactions_new (
|
||||
message_id INTEGER NOT NULL,
|
||||
emoji_id INTEGER,
|
||||
emoji_name TEXT,
|
||||
emoji_flags INTEGER NOT NULL,
|
||||
count INTEGER NOT NULL,
|
||||
FOREIGN KEY (message_id) REFERENCES messages (message_id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
)
|
||||
""");
|
||||
await conn.ExecuteAsync("INSERT INTO message_reactions_new (message_id, emoji_id, emoji_name, emoji_flags, count) SELECT message_id, emoji_id, emoji_name, emoji_flags, count FROM message_reactions WHERE message_id IN (SELECT DISTINCT message_id FROM messages)");
|
||||
|
||||
await reporter.MainWork("Migrating message edit timestamps...", 2, 5);
|
||||
await conn.ExecuteAsync("""
|
||||
CREATE TABLE message_edit_timestamps_new (
|
||||
message_id INTEGER PRIMARY KEY NOT NULL,
|
||||
edit_timestamp INTEGER NOT NULL,
|
||||
FOREIGN KEY (message_id) REFERENCES messages (message_id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
)
|
||||
""");
|
||||
await conn.ExecuteAsync("INSERT INTO message_edit_timestamps_new (message_id, edit_timestamp) SELECT message_id, edit_timestamp FROM message_edit_timestamps WHERE message_id IN (SELECT DISTINCT message_id FROM messages)");
|
||||
|
||||
await reporter.MainWork("Migrating message replies...", 3, 5);
|
||||
await conn.ExecuteAsync("""
|
||||
CREATE TABLE message_replied_to_new (
|
||||
message_id INTEGER PRIMARY KEY NOT NULL,
|
||||
replied_to_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (message_id) REFERENCES messages (message_id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
)
|
||||
""");
|
||||
await conn.ExecuteAsync("INSERT INTO message_replied_to_new (message_id, replied_to_id) SELECT message_id, replied_to_id FROM message_replied_to WHERE message_id IN (SELECT DISTINCT message_id FROM messages)");
|
||||
|
||||
await reporter.MainWork("Applying schema changes...", 4, 5);
|
||||
|
||||
await conn.ExecuteAsync("DROP TABLE message_embeds");
|
||||
await conn.ExecuteAsync("ALTER TABLE message_embeds_new RENAME TO message_embeds");
|
||||
await conn.ExecuteAsync("CREATE INDEX embeds_message_ix ON message_embeds(message_id)");
|
||||
|
||||
await conn.ExecuteAsync("DROP TABLE message_reactions");
|
||||
await conn.ExecuteAsync("ALTER TABLE message_reactions_new RENAME TO message_reactions");
|
||||
await conn.ExecuteAsync("CREATE INDEX reactions_message_ix ON message_reactions(message_id)");
|
||||
|
||||
await conn.ExecuteAsync("DROP TABLE message_edit_timestamps");
|
||||
await conn.ExecuteAsync("ALTER TABLE message_edit_timestamps_new RENAME TO message_edit_timestamps");
|
||||
|
||||
await conn.ExecuteAsync("DROP TABLE message_replied_to");
|
||||
await conn.ExecuteAsync("ALTER TABLE message_replied_to_new RENAME TO message_replied_to");
|
||||
}
|
||||
}
|
@@ -7,11 +7,19 @@ sealed class SqliteSchemaUpgradeTo3 : ISchemaUpgrade {
|
||||
async Task ISchemaUpgrade.Run(ISqliteConnection conn, ISchemaUpgradeCallbacks.IProgressReporter reporter) {
|
||||
await reporter.MainWork("Applying schema changes...", 0, 1);
|
||||
|
||||
await SqliteSchema.CreateMessageEditTimestampTable(conn);
|
||||
await conn.ExecuteAsync("ALTER TABLE message_edit_timestamps RENAME TO edit_timestamps");
|
||||
await conn.ExecuteAsync("""
|
||||
CREATE TABLE edit_timestamps (
|
||||
message_id INTEGER PRIMARY KEY NOT NULL,
|
||||
edit_timestamp INTEGER NOT NULL
|
||||
)
|
||||
""");
|
||||
|
||||
await SqliteSchema.CreateMessageRepliedToTable(conn);
|
||||
await conn.ExecuteAsync("ALTER TABLE message_replied_to RENAME TO replied_to");
|
||||
await conn.ExecuteAsync("""
|
||||
CREATE TABLE replied_to (
|
||||
message_id INTEGER PRIMARY KEY NOT NULL,
|
||||
replied_to_id INTEGER NOT NULL
|
||||
)
|
||||
""");
|
||||
|
||||
await conn.ExecuteAsync("""
|
||||
INSERT INTO edit_timestamps (message_id, edit_timestamp)
|
||||
|
@@ -8,7 +8,7 @@ using DHT.Utils.Logging;
|
||||
namespace DHT.Server.Database.Sqlite;
|
||||
|
||||
sealed class SqliteSchema {
|
||||
internal const int Version = 9;
|
||||
internal const int Version = 10;
|
||||
|
||||
private static readonly Log Log = Log.ForType<SqliteSchema>();
|
||||
|
||||
@@ -100,7 +100,8 @@ sealed class SqliteSchema {
|
||||
await conn.ExecuteAsync("""
|
||||
CREATE TABLE message_embeds (
|
||||
message_id INTEGER NOT NULL,
|
||||
json TEXT NOT NULL
|
||||
json TEXT NOT NULL,
|
||||
FOREIGN KEY (message_id) REFERENCES messages (message_id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
)
|
||||
""");
|
||||
|
||||
@@ -110,12 +111,27 @@ sealed class SqliteSchema {
|
||||
emoji_id INTEGER,
|
||||
emoji_name TEXT,
|
||||
emoji_flags INTEGER NOT NULL,
|
||||
count INTEGER NOT NULL
|
||||
count INTEGER NOT NULL,
|
||||
FOREIGN KEY (message_id) REFERENCES messages (message_id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
)
|
||||
""");
|
||||
|
||||
await conn.ExecuteAsync("""
|
||||
CREATE TABLE message_edit_timestamps (
|
||||
message_id INTEGER PRIMARY KEY NOT NULL,
|
||||
edit_timestamp INTEGER NOT NULL,
|
||||
FOREIGN KEY (message_id) REFERENCES messages (message_id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
)
|
||||
""");
|
||||
|
||||
await conn.ExecuteAsync("""
|
||||
CREATE TABLE message_replied_to (
|
||||
message_id INTEGER PRIMARY KEY NOT NULL,
|
||||
replied_to_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (message_id) REFERENCES messages (message_id) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
)
|
||||
""");
|
||||
|
||||
await CreateMessageEditTimestampTable(conn);
|
||||
await CreateMessageRepliedToTable(conn);
|
||||
await CreateDownloadTables(conn);
|
||||
await CreateMessageAttachmentsTable(conn);
|
||||
|
||||
@@ -125,24 +141,6 @@ sealed class SqliteSchema {
|
||||
await conn.ExecuteAsync("INSERT INTO metadata (key, value) VALUES ('version', " + Version + ")");
|
||||
}
|
||||
|
||||
internal static async Task CreateMessageEditTimestampTable(ISqliteConnection conn) {
|
||||
await conn.ExecuteAsync("""
|
||||
CREATE TABLE message_edit_timestamps (
|
||||
message_id INTEGER PRIMARY KEY NOT NULL,
|
||||
edit_timestamp INTEGER NOT NULL
|
||||
)
|
||||
""");
|
||||
}
|
||||
|
||||
internal static async Task CreateMessageRepliedToTable(ISqliteConnection conn) {
|
||||
await conn.ExecuteAsync("""
|
||||
CREATE TABLE message_replied_to (
|
||||
message_id INTEGER PRIMARY KEY NOT NULL,
|
||||
replied_to_id INTEGER NOT NULL
|
||||
)
|
||||
""");
|
||||
}
|
||||
|
||||
internal static async Task CreateDownloadTables(ISqliteConnection conn) {
|
||||
await conn.ExecuteAsync("""
|
||||
CREATE TABLE download_metadata (
|
||||
@@ -185,6 +183,7 @@ sealed class SqliteSchema {
|
||||
{ 6, new SqliteSchemaUpgradeTo7() },
|
||||
{ 7, new SqliteSchemaUpgradeTo8() },
|
||||
{ 8, new SqliteSchemaUpgradeTo9() },
|
||||
{ 9, new SqliteSchemaUpgradeTo10() },
|
||||
};
|
||||
|
||||
var perf = Log.Start("from version " + dbVersion);
|
||||
|
Reference in New Issue
Block a user