Show emoji picker

FossilOrigin-Name: 3973f69d88b1e4b7394095ed335f686d2565b5242be79c7ffb1e362f38bdfcde
This commit is contained in:
nekobit 2022-08-22 16:46:59 +00:00
parent 09ddb21d42
commit f916e8d0c7
4 changed files with 20 additions and 7 deletions

View file

@ -18,7 +18,7 @@ my $rel_context = 0;
sub generate_status
{
my ($ssn, $data, $status, $notif, $is_compact) = @_;
my ($ssn, $data, $status, $notif, $is_compact, $picker) = @_;
my $boost_acct;
# Move status reference for boosts and keep account
@ -37,6 +37,7 @@ sub generate_status
status => $status,
boost => $boost_acct, # May be undef
data => $data,
emoji_picker => $picker,
notif => $notif, # May be undef
compact => $is_compact, # May be undef
is_statusey_notif => $is_statusey_notif,
@ -76,19 +77,19 @@ sub generate_status
sub content_status
{
my ($ssn, $data, $status, $statuses_before, $statuses_after) = @_;
my ($ssn, $data, $status, $statuses_before, $statuses_after, $picker) = @_;
$rel_context = 0;
my %vars = (
prefix => '',
ssn => $ssn,
data => $data,
status => $status,
picker => $picker,
statuses_before => $statuses_before,
statuses_after => $statuses_after,
# Functions
create_status => \&generate_status,
create_status => sub { generate_status($ssn, $data, shift, 0, 0, shift) },
);

View file

@ -352,6 +352,8 @@ void content_status(PATH_ARGS, uint8_t flags)
struct mstdnt_status* statuses_before = NULL,
*statuses_after = NULL,
status = { 0 };
char* picker = NULL;
size_t picker_len;
size_t stat_before_len = 0, stat_after_len = 0;
try_post_status(ssn, api);
@ -363,6 +365,9 @@ void content_status(PATH_ARGS, uint8_t flags)
&statuses_before, &statuses_after,
&stat_before_len, &stat_after_len);
if ((flags & STATUS_EMOJI_PICKER) == STATUS_EMOJI_PICKER)
picker = construct_emoji_picker(status.id, &picker_len);
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
@ -379,6 +384,11 @@ void content_status(PATH_ARGS, uint8_t flags)
else
ARG_UNDEFINED();
if (picker)
{
XPUSHs(newSVpv(picker, picker_len));
} else ARG_UNDEFINED();
PERL_STACK_SCALAR_CALL("status::content_status");
char* dup = PERL_GET_STACK_EXIT;
@ -399,6 +409,7 @@ void content_status(PATH_ARGS, uint8_t flags)
mastodont_storage_cleanup(&storage);
mastodont_storage_cleanup(&status_storage);
Safefree(dup);
free(picker);
}
void notice_redirect(PATH_ARGS)

View file

@ -1,7 +1,7 @@
[% FOREACH i IN statuses_before %]
[% create_status(ssn, data, i) %]
[% create_status(i) %]
[% END %]
[% create_status(ssn, data, status) %]
[% create_status(status, picker) %]
[% FOREACH i IN statuses_after %]
[% create_status(ssn, data, i) %]
[% create_status(i) %]
[% END %]

View file

@ -176,6 +176,7 @@
[% icon('emoji') %]
</a>
[% IF emoji_picker -%]
aaa
[% emoji_picker %]
[%- END %]
</div>