Mark all as read, fix CSS

FossilOrigin-Name: 115f3020f24f12be0b54fcfff7088ab483fccd5029a36506e02051ec715e5b65
This commit is contained in:
nekobit 2022-08-13 05:01:19 +00:00
parent 33dbabd49b
commit 72ffa2abed
6 changed files with 76 additions and 7 deletions

29
dist/treebird.css vendored
View file

@ -838,14 +838,37 @@ input[type=checkbox].hidden:not(:checked) + .reply-form
/* vertical-align: middle; */
/* } */
.status.status-notification .status-content
.status.status-notification:not(.status-notification-mention) .status-content
{
color: #808080;
}
.status.status-notification .status-interact
.notification-unread
{
float: right;
position: relative;
}
.notification-unread::before
{
content:"";
position: absolute;
top: 0px;
left: 0px;
width: 15px;
height: 15px;
background: linear-gradient(135deg, rgba(255,0,0,1) 0%, rgba(0,0,0,0) 50%, rgba(0,0,0,0) 100%);
}
.notification-unread::after
{
content:"";
position: absolute;
top: 0px;
left: 0px;
width: 65px;
height: 65px;
background: linear-gradient(135deg, rgba(255,0,0,.2) 0%, rgba(0,0,0,0) 50%, rgba(0,0,0,0) 100%);
}
/***************************

View file

@ -103,6 +103,9 @@ static struct path_info paths[] = {
{ "/blocked", content_account_blocked },
{ "/muted", content_account_muted },
{ "/notifications_compact", content_notifications_compact },
{ "/notification/:/read", content_notifications_read },
{ "/notification/:/delete", content_notifications_clear },
{ "/notifications/read", content_notifications_read },
{ "/notifications/clear", content_notifications_clear },
{ "/notifications", content_notifications },
{ "/tag/:", content_tl_tag },

View file

@ -340,12 +340,51 @@ void content_notifications_clear(PATH_ARGS)
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
mastodont_notifications_clear(api, &m_args, &storage);
if (data)
{
mastodont_notification_dismiss(api, &m_args, &storage, data[0]);
}
else {
mastodont_notifications_clear(api, &m_args, &storage);
}
mastodont_storage_cleanup(&storage);
redirect(req, REDIRECT_303, referer);
}
void content_notifications_read(PATH_ARGS)
{
char* referer = GET_ENV("HTTP_REFERER", req);
struct mstdnt_args m_args;
set_mstdnt_args(&m_args, ssn);
struct mstdnt_storage storage = { 0 };
if (data)
{
struct mstdnt_notifications_args args = { .id = data[0] };
mastodont_notifications_read(api, &m_args, &args, &storage, NULL);
}
else {
mastodont_notifications_read(api, &m_args, NULL, &storage, NULL);
}
mastodont_storage_cleanup(&storage);
redirect(req, REDIRECT_303, referer);
}
// Converts it into a perl struct
static HV* perlify_notification_pleroma(struct mstdnt_notification_pleroma* notif)
{
if (!notif) return NULL;
HV* notif_pl_hv = newHV();
hvstores_int(notif_pl_hv, "is_muted", notif->is_muted);
hvstores_int(notif_pl_hv, "is_seen", notif->is_seen);
return notif_pl_hv;
}
// Converts it into a perl struct
HV* perlify_notification(struct mstdnt_notification* notif)
{
@ -357,6 +396,7 @@ HV* perlify_notification(struct mstdnt_notification* notif)
hvstores_str(notif_hv, "emoji", notif->emoji);
hvstores_str(notif_hv, "type", mstdnt_notification_t_to_str(notif->type));
hvstores_ref(notif_hv, "account", perlify_account(notif->account));
hvstores_ref(notif_hv, "pleroma", perlify_notification_pleroma(notif->pleroma));
hvstores_ref(notif_hv, "status", perlify_status(notif->status));
return notif_hv;
@ -380,5 +420,4 @@ AV* perlify_notifications(struct mstdnt_notification* notifs, size_t len)
void api_notifications(PATH_ARGS)
{
send_result(req, NULL, "application/json", "{\"status\":0}", 0);
}

View file

@ -50,6 +50,7 @@ char* construct_notifications_compact(struct session* ssn,
void content_notifications(PATH_ARGS);
void content_notifications_compact(PATH_ARGS);
void content_notifications_clear(PATH_ARGS);
void content_notifications_read(PATH_ARGS);
void api_notifications(PATH_ARGS);

View file

@ -3,8 +3,10 @@
<div class="menubar">
[% IF notifs %]
<a class="btn btn-single btn-small" href="/notifications/clear">Clear notifications</a>
<a class="btn btn-single btn-small" href="/notifications/read">Mark as read</a>
[% ELSE %]
<span class="btn btn-single btn-small btn-disabled">Clear notifications</span>
<span class="btn btn-single btn-small btn-disabled">Mark as read</span>
[% END %]
</div>
[% IF notifs %]

View file

@ -1,6 +1,7 @@
<input type="checkbox" class="status-hide" id="status-toggle-[% status.id %]"[% IF status.muted %] checked[% END %]>
<div class="status
[%- IF notif %] status-notification[% END %]
[%- IF notif %] status-notification[% IF notif.pleroma && !notif.pleroma.is_seen %] notification-unread[% END %][% END %]
[%- IF is_statusey_notif -%] status-notification-mention[% END %]
[%# Blame CSS for this class %]
[%- IF boost || (notif && notif.account && !is_statusey_notif) %] notification-info-lookahead[% END -%]
" id="[% status.id %]">
@ -115,7 +116,7 @@
</div>
[% END %]
<div class="status-interact">
[% UNLESS notif || is_statusey_notif %]
[% IF !notif || is_statusey_notif %]
<div class="status-buttons">
<label for="status-quickreply-[% status.id %]" class="pointer statbtn reply-btn">
[% icon('reply') %]