From f916e8d0c7d7c7c777edb89b000f7fdaeba6884a Mon Sep 17 00:00:00 2001 From: nekobit Date: Mon, 22 Aug 2022 16:46:59 +0000 Subject: [PATCH] Show emoji picker FossilOrigin-Name: 3973f69d88b1e4b7394095ed335f686d2565b5242be79c7ffb1e362f38bdfcde --- perl/status.pm | 9 +++++---- src/status.c | 11 +++++++++++ templates/content_status.tt | 6 +++--- templates/status.tt | 1 + 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/perl/status.pm b/perl/status.pm index 48d65c1..c366900 100644 --- a/perl/status.pm +++ b/perl/status.pm @@ -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) }, ); diff --git a/src/status.c b/src/status.c index 39e8b71..60a9fb5 100644 --- a/src/status.c +++ b/src/status.c @@ -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) diff --git a/templates/content_status.tt b/templates/content_status.tt index 3cd6cc9..578ef39 100644 --- a/templates/content_status.tt +++ b/templates/content_status.tt @@ -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 %] diff --git a/templates/status.tt b/templates/status.tt index 63289cb..f2654c3 100644 --- a/templates/status.tt +++ b/templates/status.tt @@ -176,6 +176,7 @@ [% icon('emoji') %] [% IF emoji_picker -%] + aaa [% emoji_picker %] [%- END %]