From 55afbcdab44406995510c9dff6139982c0e3a031 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 25 Jul 2024 02:16:27 +0300 Subject: [PATCH] add search suggestions in bookmarks --- .../Page/Navbar/Request/Completion.php | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Entity/Browser/Container/Page/Navbar/Request/Completion.php b/src/Entity/Browser/Container/Page/Navbar/Request/Completion.php index 7fbd8a9f..9e81cd46 100644 --- a/src/Entity/Browser/Container/Page/Navbar/Request/Completion.php +++ b/src/Entity/Browser/Container/Page/Navbar/Request/Completion.php @@ -62,19 +62,36 @@ class Completion public function refresh( int $limit = 5, - int $offset = 0 + int $offset = 0, + array $suggestions = [] ): void { $this->suggestion->clear(); + foreach ($this->request->navbar->page->container->browser->database->findBookmark( + $this->request->getValue(), + $offset, + $limit + ) as $history) + { + $suggestions[] = $history->request; + } + foreach ($this->request->navbar->page->container->browser->database->findHistory( $this->request->getValue(), $offset, $limit ) as $history) { + $suggestions[] = $history->url; + } + + foreach (array_values(array_unique($suggestions)) as $index => $suggestion) + { + if ($index > $limit) break; + $this->suggestion->append( - $history->url + $suggestion ); } }