Skip to content

Commit

Permalink
feat: add button to reset first-time setup
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-is-cute committed Sep 30, 2024
1 parent c39bf39 commit f9062b6
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions Ui/Tabs/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,31 @@ ref this.Plugin.Config.OneClickCollectionId
}
}

if (!this.Plugin.Server.Listening && ImGuiHelper.CentredWideButton("Try starting server")) {
ImGui.Separator();
if (ImGui.TreeNodeEx("Miscellaneous")) {
using var treePop = new OnDispose(ImGui.TreePop);

try {
this.Plugin.Server.StartServer();
} catch (HttpListenerException ex) {
ErrorHelper.Handle(ex, "Could not start server");
this.Plugin.NotificationManager.AddNotification(new Notification {
Type = NotificationType.Error,
MinimizedText = "Could not start server",
Content = $"Could not start server. {Plugin.Name} will not be able to work with the website.",
InitialDuration = TimeSpan.FromSeconds(5),
});
if (this.Plugin.Config.FirstTimeSetupComplete && ImGuiHelper.CentredWideButton("Reset first-time setup")) {
anyChanged = true;
this.Plugin.Config.FirstTimeSetupComplete = false;
this.Plugin.DoFirstTimeSetup();
}

if (!this.Plugin.Server.Listening && ImGuiHelper.CentredWideButton("Try starting server")) {
try {
this.Plugin.Server.StartServer();
} catch (HttpListenerException ex) {
ErrorHelper.Handle(ex, "Could not start server");
this.Plugin.NotificationManager.AddNotification(new Notification {
Type = NotificationType.Error,
MinimizedText = "Could not start server",
Content = $"Could not start server. {Plugin.Name} will not be able to work with the website.",
InitialDuration = TimeSpan.FromSeconds(5),
});
}
}
}


ImGui.Separator();

var version = Plugin.Version ?? "???";
Expand Down

0 comments on commit f9062b6

Please sign in to comment.