FIX: Do not explode if search result is empty (#107)

FIX: Do not explode if search result is empty (#107)

results.grouped_search_result.type_filter is undefined if no results are returned.

diff --git a/assets/javascripts/discourse/initializers/add-search-results.js b/assets/javascripts/discourse/initializers/add-search-results.js
index dda97c7..828a447 100644
--- a/assets/javascripts/discourse/initializers/add-search-results.js
+++ b/assets/javascripts/discourse/initializers/add-search-results.js
@@ -77,7 +77,9 @@ export default {
     const session = container.lookup("session:main");
     withPluginApi("0.11.3", (api) => {
       api.addSearchResultsCallback((results) => {
-        if (results.grouped_search_result.type_filter !== "private_messages") {
+        if (
+          results?.grouped_search_result?.type_filter !== "private_messages"
+        ) {
           return Promise.resolve(results);
         }
 

GitHub sha: 043bd2c793c58dc96098480d6d4c92ab84376be9

This commit appears in #107 which was approved by nbianca. It was merged by udan11.