« get me outta code hell

client: show results from generic search - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/static
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-05-05 13:14:27 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-05-31 12:11:49 -0300
commitb76fdc3b5ef0ce800c78014bfb879a5acc0329a9 (patch)
treefd98e4619d0ad0379a77af2f7089dbd9354a7d74 /src/static
parent5131c2d7928bb93118b40008513488e3e8d98fc7 (diff)
client: show results from generic search
Diffstat (limited to 'src/static')
-rw-r--r--src/static/js/client.js45
1 files changed, 25 insertions, 20 deletions
diff --git a/src/static/js/client.js b/src/static/js/client.js
index d613bc6a..560a0d36 100644
--- a/src/static/js/client.js
+++ b/src/static/js/client.js
@@ -3714,19 +3714,40 @@ function showSidebarSearchResults(results) {
   cssProp(info.resultsContainer, 'display', 'block');
 
   for (const result of flatResults) {
-    if (result.index !== 'tracks') continue;
-    info.results.appendChild(generateSidebarSearchTrackResult(result));
+    if (result.index !== 'generic') continue;
+
+    const el = generateSidebarSearchResult(result);
+    if (!el) continue;
+
+    info.results.appendChild(el);
   }
 }
 
 function generateSidebarSearchResult(result) {
+  const preparedSlots = {
+    color:
+      result.data.color ?? null,
+
+    name:
+      result.data.name ?? result.data.primaryName ?? null,
+
+    imageSource:
+      getSearchResultImageSource(result),
+  };
+
   switch (result.referenceType) {
-    case 'track':
-      return generateSidebarSearchTrackResult(result);
+    case 'track': {
+      preparedSlots.href =
+        openTrack(result.directory);
+
+      break;
+    }
 
     default:
       return null;
   }
+
+  return generateSidebarSearchResultTemplate(preparedSlots);
 }
 
 function getSearchResultImageSource(result) {
@@ -3757,22 +3778,6 @@ function getSearchResultImageSource(result) {
   }
 }
 
-function generateSidebarSearchTrackResult(result) {
-  return generateSidebarSearchResultTemplate({
-    href:
-      openTrack(result.directory),
-
-    color:
-      result.data.color,
-
-    name:
-      result.data.name,
-
-    imageSource:
-      getSearchResultImageSource(result),
-  });
-}
-
 function generateSidebarSearchResultTemplate(slots) {
   const link = document.createElement('a');
   link.classList.add('wiki-search-result');