summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data.c8
-rw-r--r--html.c24
2 files changed, 25 insertions, 7 deletions
diff --git a/data.c b/data.c
index c466598..bae85a1 100644
--- a/data.c
+++ b/data.c
@@ -901,11 +901,11 @@ int object_user_cache_in(snac *snac, const char *id, const char *cachedir)
}
-xs_list *object_user_cache_list(snac *snac, const char *cachedir, int max)
+xs_list *object_user_cache_list(snac *snac, const char *cachedir, int max, int inv)
/* returns the objects in a cache as a list */
{
xs *idx = xs_fmt("%s/%s.idx", snac->basedir, cachedir);
- return index_list(idx, max);
+ return inv ? index_list_desc(idx, 0, max) : index_list(idx, max);
}
@@ -945,7 +945,7 @@ int follower_check(snac *snac, const char *actor)
xs_list *follower_list(snac *snac)
/* returns the list of followers */
{
- xs *list = object_user_cache_list(snac, "followers", XS_ALL);
+ xs *list = object_user_cache_list(snac, "followers", XS_ALL, 0);
xs_list *fwers = xs_list_new();
char *p, *v;
@@ -1408,7 +1408,7 @@ int unpin(snac *user, const char *id)
xs_list *pinned_list(snac *user)
/* return the lists of pinned posts */
{
- return object_user_cache_list(user, "pinned", XS_ALL);
+ return object_user_cache_list(user, "pinned", XS_ALL, 1);
}
diff --git a/html.c b/html.c
index ff0e6df..5118042 100644
--- a/html.c
+++ b/html.c
@@ -657,9 +657,17 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch
s = xs_str_cat(s, s1);
}
- if (xs_list_in(likes, snac->md5) == -1) {
- /* not already liked; add button */
- s = html_button(s, "like", L("Like"));
+ if (!xs_startswith(id, snac->actor)) {
+ if (xs_list_in(likes, snac->md5) == -1) {
+ /* not already liked; add button */
+ s = html_button(s, "like", L("Like"));
+ }
+ }
+ else {
+ if (is_pinned(snac, id))
+ s = html_button(s, "unpin", L("Unpin"));
+ else
+ s = html_button(s, "pin", L("Pin"));
}
if (is_msg_public(snac, msg)) {
@@ -2090,6 +2098,16 @@ int html_post_handler(const xs_dict *req, const char *q_path,
}
}
else
+ if (strcmp(action, L("Pin")) == 0) { /** **/
+ pin(&snac, id);
+ timeline_touch(&snac);
+ }
+ else
+ if (strcmp(action, L("Unpin")) == 0) { /** **/
+ unpin(&snac, id);
+ timeline_touch(&snac);
+ }
+ else
status = 404;
/* delete the cached timeline */