Skip to content

Commit

Permalink
chore: disable clear data button
Browse files Browse the repository at this point in the history
  • Loading branch information
taciturnaxolotl committed Dec 20, 2024
1 parent 668a61e commit 8de1b76
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
36 changes: 20 additions & 16 deletions routes/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,26 +707,30 @@ func (h *SettingsHandler) actionRegenerateSummaries(w http.ResponseWriter, r *ht
}

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

user := middlewares.GetPrincipal(r)
slog.Info("user requested to delete all data", "userID", user.ID)
// if h.config.IsDev() {
// loadTemplates()
// }

go func(user *models.User) {
slog.Info("deleting summaries for user", "userID", user.ID)
if err := h.summarySrvc.DeleteByUser(user.ID); err != nil {
conf.Log().Request(r).Error("failed to clear summaries", "error", err)
}
// user := middlewares.GetPrincipal(r)
// slog.Info("user requested to delete all data", "userID", user.ID)

slog.Info("deleting heartbeats for user", "userID", user.ID)
if err := h.heartbeatSrvc.DeleteByUser(user); err != nil {
conf.Log().Request(r).Error("failed to clear heartbeats", "error", err)
}
}(user)
// go func(user *models.User) {
// slog.Info("deleting summaries for user", "userID", user.ID)
// if err := h.summarySrvc.DeleteByUser(user.ID); err != nil {
// conf.Log().Request(r).Error("failed to clear summaries", "error", err)
// }

// slog.Info("deleting heartbeats for user", "userID", user.ID)
// if err := h.heartbeatSrvc.DeleteByUser(user); err != nil {
// conf.Log().Request(r).Error("failed to clear heartbeats", "error", err)
// }
// }(user)

return actionResult{http.StatusAccepted, "deletion in progress, this may take a couple of seconds", "", nil}
// return actionResult{http.StatusAccepted, "deletion in progress, this may take a couple of seconds", "", nil}
}

func (h *SettingsHandler) actionDeleteUser(w http.ResponseWriter, r *http.Request) actionResult {
Expand Down
7 changes: 6 additions & 1 deletion views/settings.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,11 @@
class="font-semibold text-text-primary dark:text-text-dark-primary"
>Clear Data</span
>
<span
class="block text-sm text-red-600"
>
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.
</span>
<span
class="block text-sm text-text-secondary dark:text-text-dark-secondary"
>
Expand All @@ -2117,7 +2122,7 @@
<div class="w-1/2 ml-4 flex items-center">
<button
type="button"
class="btn-danger ml-1"
class="btn-danger ml-1 opacity-50 cursor-not-allowed"
@click.stop="confirmClearData"
>
Clear data
Expand Down

0 comments on commit 8de1b76

Please sign in to comment.