Skip to content

Commit 31b0f7a

Browse files
feat: reenable the clear data button
Amp-Thread-ID: https://ampcode.com/threads/T-51351ea9-26d6-45ff-8147-c1f3f90021a8 Co-authored-by: Amp <amp@ampcode.com>
1 parent 1db2fc0 commit 31b0f7a

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

routes/settings.go

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -707,30 +707,26 @@ func (h *SettingsHandler) actionRegenerateSummaries(w http.ResponseWriter, r *ht
707707
}
708708

709709
func (h *SettingsHandler) actionClearData(w http.ResponseWriter, r *http.Request) actionResult {
710-
// return error cannot delete user contact high seas support for help
711-
routeutils.SetError(r, w, "Cannot clear your data. Please contact support for help.")
712-
return actionResult{-1, "", "", nil}
713-
714-
// if h.config.IsDev() {
715-
// loadTemplates()
716-
// }
710+
if h.config.IsDev() {
711+
loadTemplates()
712+
}
717713

718-
// user := middlewares.GetPrincipal(r)
719-
// slog.Info("user requested to delete all data", "userID", user.ID)
714+
user := middlewares.GetPrincipal(r)
715+
slog.Info("user requested to delete all data", "userID", user.ID)
720716

721-
// go func(user *models.User) {
722-
// slog.Info("deleting summaries for user", "userID", user.ID)
723-
// if err := h.summarySrvc.DeleteByUser(user.ID); err != nil {
724-
// conf.Log().Request(r).Error("failed to clear summaries", "error", err)
725-
// }
717+
go func(user *models.User) {
718+
slog.Info("deleting summaries for user", "userID", user.ID)
719+
if err := h.summarySrvc.DeleteByUser(user.ID); err != nil {
720+
conf.Log().Request(r).Error("failed to clear summaries", "error", err)
721+
}
726722

727-
// slog.Info("deleting heartbeats for user", "userID", user.ID)
728-
// if err := h.heartbeatSrvc.DeleteByUser(user); err != nil {
729-
// conf.Log().Request(r).Error("failed to clear heartbeats", "error", err)
730-
// }
731-
// }(user)
723+
slog.Info("deleting heartbeats for user", "userID", user.ID)
724+
if err := h.heartbeatSrvc.DeleteByUser(user); err != nil {
725+
conf.Log().Request(r).Error("failed to clear heartbeats", "error", err)
726+
}
727+
}(user)
732728

733-
// return actionResult{http.StatusAccepted, "deletion in progress, this may take a couple of seconds", "", nil}
729+
return actionResult{http.StatusAccepted, "deletion in progress, this may take a couple of seconds", "", nil}
734730
}
735731

736732
func (h *SettingsHandler) actionDeleteUser(w http.ResponseWriter, r *http.Request) actionResult {

views/settings.tpl.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,11 +2107,7 @@
21072107
class="font-semibold text-text-primary dark:text-text-dark-primary"
21082108
>Clear Data</span
21092109
>
2110-
<span
2111-
class="block text-sm text-red-600"
2112-
>
2113-
Warning: Clearing your data is not allowed during High Seas. Please contact us in <a href="https://hackclub.slack.com/archives/C07PZNMBPBN">#high-seas-help</a> for more information.
2114-
</span>
2110+
21152111
<span
21162112
class="block text-sm text-text-secondary dark:text-text-dark-secondary"
21172113
>
@@ -2122,7 +2118,7 @@
21222118
<div class="w-1/2 ml-4 flex items-center">
21232119
<button
21242120
type="button"
2125-
class="btn-danger ml-1 opacity-50 cursor-not-allowed"
2121+
class="btn-danger ml-1"
21262122
@click.stop="confirmClearData"
21272123
>
21282124
Clear data

0 commit comments

Comments
 (0)