Add button to database section
This commit is contained in:
Generated
+9
@@ -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>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Database.
|
/// Looks up a localized string similar to Database.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1009,4 +1009,7 @@
|
|||||||
<data name="Options_Database_Old_Delete_Success" xml:space="preserve">
|
<data name="Options_Database_Old_Delete_Success" xml:space="preserve">
|
||||||
<value>The old database was successfully removed.</value>
|
<value>The old database was successfully removed.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Options_Database_Old_Migration" xml:space="preserve">
|
||||||
|
<value>Open migration window</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ internal class LegacyMessageImporterWindow : Window
|
|||||||
private void DrawEligible()
|
private void DrawEligible()
|
||||||
{
|
{
|
||||||
ImGui.TextWrapped("Import database messages from legacy LiteDB database to SQLite database?");
|
ImGui.TextWrapped("Import database messages from legacy LiteDB database to SQLite database?");
|
||||||
ImGui.Text($"Message count: {Eligibility.MessageCount:N0}");
|
ImGui.TextWrapped($"Message count: {Eligibility.MessageCount:N0}");
|
||||||
ImGui.Text($"Database size: {StringUtil.BytesToString(Eligibility.DatabaseSizeBytes)}");
|
ImGui.TextWrapped($"Database size: {StringUtil.BytesToString(Eligibility.DatabaseSizeBytes)}");
|
||||||
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
@@ -126,20 +126,20 @@ internal class LegacyMessageImporterWindow : Window
|
|||||||
|
|
||||||
private void DrawIneligible()
|
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)
|
switch (Eligibility.Status)
|
||||||
{
|
{
|
||||||
case LegacyMessageImporterEligibilityStatus.IneligibleOriginalDbNotExists:
|
case LegacyMessageImporterEligibilityStatus.IneligibleOriginalDbNotExists:
|
||||||
ImGui.Text("The old database could not be found.");
|
ImGui.TextWrapped("The old database could not be found.");
|
||||||
break;
|
break;
|
||||||
case LegacyMessageImporterEligibilityStatus.IneligibleMigrationDbExists:
|
case LegacyMessageImporterEligibilityStatus.IneligibleMigrationDbExists:
|
||||||
ImGui.Text("The migration process was already started.");
|
ImGui.TextWrapped("The migration process was already started.");
|
||||||
break;
|
break;
|
||||||
case LegacyMessageImporterEligibilityStatus.IneligibleLiteDbFailed:
|
case LegacyMessageImporterEligibilityStatus.IneligibleLiteDbFailed:
|
||||||
ImGui.Text("The old database could not be opened.");
|
ImGui.TextWrapped("The old database could not be opened.");
|
||||||
break;
|
break;
|
||||||
case LegacyMessageImporterEligibilityStatus.IneligibleNoMessages:
|
case LegacyMessageImporterEligibilityStatus.IneligibleNoMessages:
|
||||||
ImGui.Text("The old database contains no messages.");
|
ImGui.TextWrapped("The old database contains no messages.");
|
||||||
break;
|
break;
|
||||||
case LegacyMessageImporterEligibilityStatus.Eligible:
|
case LegacyMessageImporterEligibilityStatus.Eligible:
|
||||||
default:
|
default:
|
||||||
@@ -147,7 +147,7 @@ internal class LegacyMessageImporterWindow : Window
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(Eligibility.AdditionalIneligibilityInfo))
|
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
|
// LiteDB failures notify the user, so give them a chance to rename the
|
||||||
// database to avoid prompting again.
|
// database to avoid prompting again.
|
||||||
|
|||||||
@@ -53,16 +53,29 @@ internal sealed class Database : ISettingsTab
|
|||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
var old = new FileInfo(Path.Join(Plugin.Interface.ConfigDirectory.FullName, "chat.db"));
|
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)
|
if (old.Exists)
|
||||||
{
|
{
|
||||||
ImGui.TextUnformatted(Language.Options_Database_Old_Heading);
|
ImGui.TextUnformatted(Language.Options_Database_Old_Heading);
|
||||||
ImGui.Spacing();
|
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))
|
if (ImGuiUtil.CtrlShiftButton(Language.Options_Database_Old_Delete, Language.Options_Database_Old_Delete_Tooltip))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
old.Delete();
|
migratedOld.Delete();
|
||||||
WrapperUtil.AddNotification(Language.Options_Database_Old_Delete_Success, NotificationType.Success);
|
WrapperUtil.AddNotification(Language.Options_Database_Old_Delete_Success, NotificationType.Success);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
Reference in New Issue
Block a user