Errors and fix autovivification with statuses in account

FossilOrigin-Name: f1e729fac2faaf4aa483d98f29712f752de726f9c2063cfa6fa35551cc5d92e9
This commit is contained in:
nekobit 2022-08-11 04:56:32 +00:00
parent d789caec0a
commit b3c3fe360a
9 changed files with 65 additions and 15 deletions

34
dist/treebird.css vendored
View file

@ -411,6 +411,14 @@ table.present th, table.present td
color: #666;
}
.fancy-error-subtext
{
display: block;
margin: 12px 24px 0 24px;
font-size: 1rem;
color: #222;
}
.fancy-error-kaomoji
{
display: block;
@ -842,7 +850,8 @@ input[type=checkbox].hidden:not(:checked) + .reply-form
/***************************
* Statuses *
**************************/
.status
.status,
.notification-regular
{
padding: 11px;
padding-bottom: 6px;
@ -1021,6 +1030,12 @@ input[type=checkbox].hidden:not(:checked) + .reply-form
padding: 0 0 0 10px;
}
.notification-regular .notification-content
{
margin-top: 4px;
font-size: 14px;
}
.status .status-info > table.ui-table
{
width: 100%;
@ -1082,11 +1097,11 @@ input[type=checkbox].hidden:not(:checked) + .reply-form
min-width: 0;
}
.status .notification-text-group-with-icon .username
{
/* UNDO */
vertical-align: unset;
}
/* .status .notification-text-group-with-icon .username */
/* { */
/* /\* UNDO *\/ */
/* vertical-align: unset; */
/* } */
.status .status-content
{
@ -1519,6 +1534,11 @@ p}
background: linear-gradient(#aa0000, #600000);
}
.action
{
vertical-align: middle;
}
/****************
* Statusbox *
****************/
@ -2248,7 +2268,7 @@ input[type=checkbox].hidden:not(:checked) + .list-edit-content
{
color: #ccc;
font-size: 8px;
margin: unset;e
margin: unset;
}
#instance-panel + .mini-links

View file

@ -1,6 +1,7 @@
package account;
use strict;
use warnings;
use Data::Dumper;
use Exporter 'import';
@ -9,7 +10,7 @@ our @EXPORT = qw( account content_statuses );
use template_helpers 'to_template';
use l10n 'lang';
use status 'generate_status';
use string_helpers qw( simple_escape emojify );
use string_helpers qw( simple_escape emojify random_error_kaomoji );
use navigation 'generate_navigation';
sub generate_account
@ -40,7 +41,9 @@ sub content_statuses
acct => $acct,
statuses => $statuses,
create_status => sub { generate_status($ssn, $data, shift); },
nav => generate_navigation($ssn, $data, $statuses->[0]->{id}, $statuses->[-1]->{id}),
# Make subroutine so Perl doesn't autovivify
nav => sub { generate_navigation($ssn, $data, $statuses->[0]->{id}, $statuses->[-1]->{id}) },
random_error_kaomoji => \&random_error_kaomoji,
);
generate_account($ssn, $data, $acct, $relationship, to_template(\%vars, \$data->{'account_statuses.tt'}));

View file

@ -42,6 +42,8 @@ sub get_icon_svg
unlisted => '<svg class="visibility vis-unlisted" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 9.9-1"></path></svg>',
public => '<svg class="visibility vis-public" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>',
follow => '<svg class="follow" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="8.5" cy="7" r="4"></circle><line x1="20" y1="8" x2="20" y2="14"></line><line x1="23" y1="11" x2="17" y2="11"></line></svg>',
);
$res{$_[0]};

View file

@ -8,6 +8,7 @@ our @EXPORT = qw( generate_notification_compact content_notifications );
use template_helpers 'to_template';
use status 'generate_status';
use string_helpers qw( random_error_kaomoji );
use icons 'get_icon';
sub generate_notification_compact
{
@ -31,6 +32,7 @@ sub content_notifications
ssn => $ssn,
notifs => $notifs,
create_status => sub { generate_status($ssn, $data, shift, shift); },
icon => \&get_icon,
random_error_kaomoji => \&random_error_kaomoji,
);

View file

@ -56,6 +56,7 @@ sub emojify
sub format_username
{
my $account = shift;
return unless $account;
#TODO ESCAPE DISPLAY NAME
emojify(simple_escape($account->{display_name}), $account->{emojis});

View file

@ -246,7 +246,7 @@ static char* account_statuses_cb(HV* session_hv,
XPUSHs(newRV_noinc((SV*)perlify_relationship(rel)));
else ARG_UNDEFINED();
if (statuses)
if (statuses && statuses_len)
XPUSHs(newRV_noinc((SV*)perlify_statuses(statuses, statuses_len)));
else ARG_UNDEFINED();

View file

@ -2,7 +2,11 @@
[% FOREACH i IN statuses %]
[% create_status(i) %]
[% END %]
[% nav %]
[% nav() %]
[% ELSE %]
<p>No statuses...</p>
<div class="fancy-error">
<span class="fancy-error-kaomoji">[% random_error_kaomoji() %]</span>
<span class="fancy-error-text">No statuses.</span>
<span class="fancy-error-subtext">Either this user just lurks, or their posts have not yet federated. Usually the latter occurs on new instances.</span>
</div>
[% END %]

View file

@ -22,7 +22,25 @@
notif.type == 'poll' %]
[% create_status(notif.status, notif) %]
[% ELSIF notif.type == 'follow' || notif.type == 'follow request' %]
Someone attempted to follow you
<table class="notification notification-regular ui-table">
<tr>
<td class="pfp-td">
<img src="[% notif.account.avatar %]" loading="lazy">
</td>
<td class="notification-info">
<div class="notification-info-format">
<span class="notification-text-group-with-icon">
<span title="[% notif.account.acct %]" class="username">[% notif.account.display_name %]</span>
<span class="action">followed</span>
</span>
[% icon('follow') %]
</div>
<div class="notification-content">
<a href="/@[% notif.account.acct %]">@[% notif.account.acct %]</a>
</div>
</td>
</tr>
</table>
[% END %]
[% END %]
[% ELSE %]

View file

@ -22,8 +22,8 @@
</span>
</span>
[% IF notif && notif.type == 'favourite' %]
[% icon('favourite') %]
[% ELSIF boost || (notif && notif.type == 'boost') %] [%# It's a repeat %]
[% icon('like') %]
[% ELSIF boost || (notif && notif.type == 'reblog') %] [%# It's a repeat %]
[% icon('repeat') %]
[% END %]
</div>