Browse Source

New button to clear all notifications.

default 2 years ago
parent
commit
048ee35039
1 changed files with 13 additions and 0 deletions
  1. 13 0
      html.c

+ 13 - 0
html.c

@@ -1199,6 +1199,12 @@ xs_str *html_notifications(snac *snac)
 
     s = html_user_header(snac, s, 0);
 
+    xs *s1 = xs_fmt(
+        "<form method=\"post\" action=\"%s/admin/clear-notifications\" id=\"clear\">\n"
+        "<input type=\"submit\" class=\"snac-btn-like\" value=\"%s\">\n"
+        "</form><p>", snac->actor, L("Clear all"));
+    s = xs_str_cat(s, s1);
+
     while (xs_list_iter(&p, &v)) {
         xs *noti = notify_get(snac, v);
 
@@ -1865,6 +1871,13 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
 
         status = 303;
     }
+    else
+    if (p_path && strcmp(p_path, "admin/clear-notifications") == 0) {
+        notify_clear(&snac);
+        timeline_touch(&snac);
+
+        status = 303;
+    }
 
     if (status == 303) {
         char *redir = xs_dict_get(p_vars, "redir");