From 54fa2f5585ad360a5427c2b366ce09d6eb7c54b2 Mon Sep 17 00:00:00 2001 From: Anna Date: Wed, 7 Sep 2022 02:18:12 -0400 Subject: [PATCH] delete --- client/Ui/MainWindowTabs/Settings.cs | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/client/Ui/MainWindowTabs/Settings.cs b/client/Ui/MainWindowTabs/Settings.cs index b6585c7..f3f5ae3 100644 --- a/client/Ui/MainWindowTabs/Settings.cs +++ b/client/Ui/MainWindowTabs/Settings.cs @@ -46,6 +46,7 @@ internal class Settings : ITab { } this.ExtraCodeInput(); + this.DeleteAccountButton(); ImGui.PopTextWrapPos(); } @@ -80,4 +81,35 @@ internal class Settings : ITab { } }); } + + private void DeleteAccountButton() { + var ctrl = ImGui.GetIO().KeyCtrl; + if (!ctrl) { + ImGui.BeginDisabled(); + } + + if (ImGui.Button("Delete account")) { + Task.Run(async () => { + var resp = await ServerHelper.SendRequest( + this.Plugin.Config.ApiKey, + HttpMethod.Delete, + "/account" + ); + + if (resp.IsSuccessStatusCode) { + this.Plugin.Config.ApiKey = string.Empty; + this.Plugin.SaveConfig(); + } + }); + } + + if (!ctrl) { + ImGui.EndDisabled(); + } + + ImGui.SameLine(); + ImGuiExt.HelpIcon("Hold Ctrl to enable delete button."); + + ImGui.TextUnformatted("This will delete all your messages and votes."); + } }