summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorGravatar default2022-11-21 07:57:38 +0100
committerGravatar default2022-11-21 07:57:38 +0100
commitc78574c8d9d1667a33d64224a7d1dc812963cef8 (patch)
tree9274a0d4de5c8131e36759456e75f6799ac64229 /data.c
parentIn timeline_hide(), also hide the children. (diff)
downloadsnac2-c78574c8d9d1667a33d64224a7d1dc812963cef8.tar.gz
snac2-c78574c8d9d1667a33d64224a7d1dc812963cef8.tar.xz
snac2-c78574c8d9d1667a33d64224a7d1dc812963cef8.zip
Don't hide messages (and their children) if it's already hidden.
Diffstat (limited to 'data.c')
-rw-r--r--data.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/data.c b/data.c
index 30f9888..7ac4f87 100644
--- a/data.c
+++ b/data.c
@@ -663,14 +663,18 @@ int timeline_hide(snac *snac, char *id, int hide)
663 xs *msg = xs_json_loads(s1); 663 xs *msg = xs_json_loads(s1);
664 xs *meta = xs_dup(xs_dict_get(msg, "_snac")); 664 xs *meta = xs_dup(xs_dict_get(msg, "_snac"));
665 xs *hdn = xs_val_new(hide ? XSTYPE_TRUE : XSTYPE_FALSE); 665 xs *hdn = xs_val_new(hide ? XSTYPE_TRUE : XSTYPE_FALSE);
666 char *p, *v;
666 667
667 fclose(f); 668 fclose(f);
668 669
670 /* if it's already in this hidden state, we're done */
671 if ((v = xs_dict_get(meta, "hidden")) && xs_type(v) == xs_type(hdn))
672 return ret;
673
669 meta = xs_dict_set(meta, "hidden", hdn); 674 meta = xs_dict_set(meta, "hidden", hdn);
670 msg = xs_dict_set(msg, "_snac", meta); 675 msg = xs_dict_set(msg, "_snac", meta);
671 676
672 if ((f = fopen(fn, "w")) != NULL) { 677 if ((f = fopen(fn, "w")) != NULL) {
673 char *p, *v;
674 xs *j1 = xs_json_dumps_pp(msg, 4); 678 xs *j1 = xs_json_dumps_pp(msg, 4);
675 679
676 fwrite(j1, strlen(j1), 1, f); 680 fwrite(j1, strlen(j1), 1, f);