Skip to content

Commit eee1d40

Browse files
committed
Linear: use BlockKit for "search" results too
1 parent 9369184 commit eee1d40

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

lib/Synergy/Reactor/Linear.pm

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ async sub _handle_search ($self, $event, $arg) {
315315
}
316316

317317
my $text = q{};
318-
my @blocks = bk_richsection(bk_bold("$header"));
318+
my @blocks = bk_richsection(bk_bold($header));
319319

320320
for my $node ($page->payload->{nodes}->@*) {
321321
my $icon = $want_plain ? '' : $self->_icon_for_issue($node);
@@ -480,7 +480,9 @@ command search => {
480480
}
481481
}
482482

483-
my $text = my $slack = "*Your results for «$terms»*\n";
483+
my $header = "*Your results for «$terms»";
484+
my $text = $header;
485+
my @blocks = bk_richsection(bk_bold($header));
484486

485487
for my $node ($query_result->payload->{nodes}->@*) {
486488
my $id = $node->{identifier};
@@ -538,27 +540,23 @@ command search => {
538540
}
539541

540542
if ($is_title) {
541-
$title =~ s/$_/*$_*/g for @$highlights;
542-
$title =~ s/\*@|@\*/*/g;
543-
$title =~ s/`//g;
544-
545-
$slack .= sprintf "<%s|%s> $icon %s (_assignee_: %s)\n",
546-
$url,
547-
$id,
548-
$title,
549-
$assignee,
543+
# $title =~ s/$_/*$_*/g for @$highlights;
544+
# $title =~ s/\*@|@\*/*/g;
545+
# $title =~ s/`//g;
546+
547+
push @blocks, bk_richsection(
548+
bk_link($url, $id),
549+
" $icon $title (", bk_italic("assignee"), ": $assignee)",
550+
);
550551
} else {
551-
$snippet =~ s/$_/*$_*/g for @$highlights;
552-
$snippet =~ s/\n/ /g;
553-
$snippet =~ s/\*@|@\*/*/g;
554-
$snippet =~ s/`//g;
555-
556-
$slack .= sprintf "<%s|%s> $icon %s (_assignee_: %s)\n>%s\n",
557-
$url,
558-
$id,
559-
$title,
560-
$assignee,
561-
$snippet;
552+
# $snippet =~ s/$_/*$_*/g for @$highlights;
553+
$snippet =~ s/\n/¬/g; # Replace newlines with EOL marker
554+
555+
push @blocks, bk_richsection(
556+
bk_link($url, $id),
557+
" $icon $title (", bk_italic("assignee"), ": $assignee)",
558+
"\n$snippet", # TODO: fix highlighting,
559+
);
562560
}
563561
}
564562

@@ -568,11 +566,12 @@ command search => {
568566
# Apparently 500 means "We gave up counting". UI adds the "+" too
569567
$total .= "+" if $total == 500;
570568

571-
$text .= "*[Page $cpage/$pages ($total issues)]*\n";
572-
$slack .= "*[Page $cpage of $pages ($total issues)]*\n";
569+
my $footer = "[Page $cpage/$pages ($total issues)]";
570+
$text .= "*$footer*\n";
571+
572+
push @blocks, bk_richsection(bk_bold($footer));
573573

574574
chomp $text;
575-
chomp $slack;
576575

577576
my $method = 'reply';
578577

@@ -584,7 +583,11 @@ command search => {
584583

585584
return await $event->$method(
586585
"$text",
587-
{ slack => "$slack" },
586+
{
587+
slack => {
588+
blocks => bk_blocks(bk_richblock(@blocks))->as_struct
589+
},
590+
}
588591
);
589592
});
590593
};

0 commit comments

Comments
 (0)