mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 17:45:04 +00:00
Posts can be pinned/unpinned from the web interface.
This commit is contained in:
parent
57ba1d575f
commit
eef3c419dd
2 changed files with 25 additions and 7 deletions
8
data.c
8
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
24
html.c
24
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)) {
|
||||
|
@ -2089,6 +2097,16 @@ int html_post_handler(const xs_dict *req, const char *q_path,
|
|||
snac_log(&snac, xs_fmt("deleted entry %s", id));
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue