commit c78574c

default  ·  2022-11-21 06:57:38 +0000 UTC
parent 3e71f18
Don't hide messages (and their children) if it's already hidden.
1 files changed,  +5, -1
M data.c
M data.c
+5, -1
 1@@ -663,14 +663,18 @@ int timeline_hide(snac *snac, char *id, int hide)
 2         xs *msg  = xs_json_loads(s1);
 3         xs *meta = xs_dup(xs_dict_get(msg, "_snac"));
 4         xs *hdn  = xs_val_new(hide ? XSTYPE_TRUE : XSTYPE_FALSE);
 5+        char *p, *v;
 6 
 7         fclose(f);
 8 
 9+        /* if it's already in this hidden state, we're done */
10+        if ((v = xs_dict_get(meta, "hidden")) && xs_type(v) == xs_type(hdn))
11+            return ret;
12+
13         meta = xs_dict_set(meta, "hidden", hdn);
14         msg  = xs_dict_set(msg,  "_snac",  meta);
15 
16         if ((f = fopen(fn, "w")) != NULL) {
17-            char *p, *v;
18             xs *j1 = xs_json_dumps_pp(msg, 4);
19 
20             fwrite(j1, strlen(j1), 1, f);