Remove deprecated delay helper
Change-Id: I74d205ba6fca21a8803b357f720d454ce8023e54
diff --git a/lib/Kalamar/API.pm b/lib/Kalamar/API.pm
index c58b2c7..735767a 100644
--- a/lib/Kalamar/API.pm
+++ b/lib/Kalamar/API.pm
@@ -20,6 +20,9 @@
# TODO: Correct use of stash info everywhere!
# TODO: Alot is now underneath "meta"
+# TODO:
+# Rewrite to use promises!
+
# Register the plugin
sub register {
@@ -84,7 +87,7 @@
my $user = $c->stash('user') // 'not_logged_in';
if (!$index->no_cache &&
- defined ($total_results = $c->chi->get($user . $index->_api_cache))) {
+ defined ($total_results = $c->chi->get($user . $index->_api_cache))) {
# Set total results from cache
$index->total_results($total_results);
diff --git a/lib/Kalamar/Controller/Search.pm b/lib/Kalamar/Controller/Search.pm
index cdd8851..933c7df 100644
--- a/lib/Kalamar/Controller/Search.pm
+++ b/lib/Kalamar/Controller/Search.pm
@@ -50,7 +50,11 @@
my $template = scalar $v->param('snippet') ? 'snippet' : 'search';
# Search non-blocking
- $c->delay(
+ my $tx = $c->render_later->tx;
+
+ # TODO:
+ # This should be simplified to use Promises only
+ Mojo::IOLoop->delay(
sub {
my $delay = shift;
@@ -76,7 +80,7 @@
# Render to the template
return $c->render(template => $template);
}
- );
+ )->catch(sub { $c->helpers->reply->exception(pop) and undef $tx })->wait;
};