Add button to database section

This commit is contained in:
Infi
2024-04-21 23:24:43 +02:00
parent f3530bf0fe
commit b4cb73dd0a
4 changed files with 34 additions and 9 deletions
+9
View File
@@ -1832,6 +1832,15 @@ namespace ChatTwo.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Open migration window.
/// </summary>
internal static string Options_Database_Old_Migration {
get {
return ResourceManager.GetString("Options_Database_Old_Migration", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Database.
/// </summary>
+3
View File
@@ -1009,4 +1009,7 @@
<data name="Options_Database_Old_Delete_Success" xml:space="preserve">
<value>The old database was successfully removed.</value>
</data>
<data name="Options_Database_Old_Migration" xml:space="preserve">
<value>Open migration window</value>
</data>
</root>
+8 -8
View File
@@ -97,8 +97,8 @@ internal class LegacyMessageImporterWindow : Window
private void DrawEligible()
{
ImGui.TextWrapped("Import database messages from legacy LiteDB database to SQLite database?");
ImGui.Text($"Message count: {Eligibility.MessageCount:N0}");
ImGui.Text($"Database size: {StringUtil.BytesToString(Eligibility.DatabaseSizeBytes)}");
ImGui.TextWrapped($"Message count: {Eligibility.MessageCount:N0}");
ImGui.TextWrapped($"Database size: {StringUtil.BytesToString(Eligibility.DatabaseSizeBytes)}");
ImGui.Spacing();
@@ -126,20 +126,20 @@ internal class LegacyMessageImporterWindow : Window
private void DrawIneligible()
{
ImGui.Text("Your legacy LiteDB database is not eligible for import:");
ImGui.TextWrapped("Your legacy LiteDB database is not eligible for import:");
switch (Eligibility.Status)
{
case LegacyMessageImporterEligibilityStatus.IneligibleOriginalDbNotExists:
ImGui.Text("The old database could not be found.");
ImGui.TextWrapped("The old database could not be found.");
break;
case LegacyMessageImporterEligibilityStatus.IneligibleMigrationDbExists:
ImGui.Text("The migration process was already started.");
ImGui.TextWrapped("The migration process was already started.");
break;
case LegacyMessageImporterEligibilityStatus.IneligibleLiteDbFailed:
ImGui.Text("The old database could not be opened.");
ImGui.TextWrapped("The old database could not be opened.");
break;
case LegacyMessageImporterEligibilityStatus.IneligibleNoMessages:
ImGui.Text("The old database contains no messages.");
ImGui.TextWrapped("The old database contains no messages.");
break;
case LegacyMessageImporterEligibilityStatus.Eligible:
default:
@@ -147,7 +147,7 @@ internal class LegacyMessageImporterWindow : Window
}
if (!string.IsNullOrWhiteSpace(Eligibility.AdditionalIneligibilityInfo))
ImGui.Text(Eligibility.AdditionalIneligibilityInfo);
ImGui.TextWrapped(Eligibility.AdditionalIneligibilityInfo);
// LiteDB failures notify the user, so give them a chance to rename the
// database to avoid prompting again.
+14 -1
View File
@@ -53,16 +53,29 @@ internal sealed class Database : ISettingsTab
ImGui.Spacing();
var old = new FileInfo(Path.Join(Plugin.Interface.ConfigDirectory.FullName, "chat.db"));
var migratedOld = new FileInfo(Path.Join(Plugin.Interface.ConfigDirectory.FullName, "chat-litedb.db"));
if (old.Exists)
{
ImGui.TextUnformatted(Language.Options_Database_Old_Heading);
ImGui.Spacing();
if (ImGui.Button(Language.Options_Database_Old_Migration))
Plugin.LegacyMessageImporterWindow.IsOpen = true;
ImGui.Spacing();
ImGui.Separator();
ImGui.Spacing();
}
else if (migratedOld.Exists)
{
ImGui.TextUnformatted(Language.Options_Database_Old_Heading);
ImGui.Spacing();
if (ImGuiUtil.CtrlShiftButton(Language.Options_Database_Old_Delete, Language.Options_Database_Old_Delete_Tooltip))
{
try
{
old.Delete();
migratedOld.Delete();
WrapperUtil.AddNotification(Language.Options_Database_Old_Delete_Success, NotificationType.Success);
}
catch (Exception e)