Quellcode durchsuchen

Some tweaks to the already seen mark code.

default vor 1 Jahr
Ursprung
Commit
06ba1174ca
2 geänderte Dateien mit 19 neuen und 3 gelöschten Zeilen
  1. 17 1
      data.c
  2. 2 2
      html.c

+ 17 - 1
data.c

@@ -1532,7 +1532,23 @@ void timeline_add_mark(snac *user)
 /* adds an "already seen" mark to the private timeline */
 {
     xs *fn = xs_fmt("%s/private.idx", user->basedir);
-    index_add_md5(fn, MD5_ALREADY_SEEN_MARK);
+    char last_entry[MD5_HEX_SIZE] = "";
+    FILE *f;
+
+    /* get the last entry in the index */
+    if ((f = fopen(fn, "r")) != NULL) {
+        index_desc_first(f, last_entry, 0);
+        fclose(f);
+    }
+
+    /* is the last entry *not* a mark? */
+    if (strcmp(last_entry, MD5_ALREADY_SEEN_MARK) != 0) {
+        /* add it */
+        index_add_md5(fn, MD5_ALREADY_SEEN_MARK);
+
+        /* mark as new */
+        timeline_touch(user);
+    }
 }
 
 

+ 2 - 2
html.c

@@ -2657,7 +2657,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
         /* "already seen" mark? */
         if (strcmp(v, MD5_ALREADY_SEEN_MARK) == 0) {
             if (skip == 0 && !mark_shown) {
-                xs *s = xs_fmt("%s/admin#top", user->actor);
+                xs *s = xs_fmt("%s/admin", user->actor);
 
                 xs_html_add(posts,
                     xs_html_tag("div",
@@ -2665,7 +2665,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
                         xs_html_text(L("No more unseen posts")),
                         xs_html_text(" - "),
                         xs_html_tag("a",
-                            xs_html_attr("href",  s),
+                            xs_html_attr("href", s),
                             xs_html_text(L("Back to top")))));
             }