Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): use different hiding mechanism for quick search

Elian Doran91d23bae8ebd
diff --git a/src/public/app/widgets/containers/launcher.js b/src/public/app/widgets/containers/launcher.js
index 1e281af8c5..3751cbfce4 100644
--- a/src/public/app/widgets/containers/launcher.js
+++ b/src/public/app/widgets/containers/launcher.js
@@ -61,12 +61,7 @@ export default class LauncherWidget extends BasicWidget {
}
if (!this.innerWidget) {
- if (launcherType === "builtinWidget") {
- // This allows filtering of builtin widgets based on the layout (horizontal / vertical)
- return false;
- } else {
- throw new Error(`Unknown initialization error for note '${note.noteId}', title '${note.title}'`);
- }
+ throw new Error(`Unknown initialization error for note '${note.noteId}', title '${note.title}'`);
}
this.child(this.innerWidget);
@@ -118,7 +113,7 @@ export default class LauncherWidget extends BasicWidget {
case "todayInJournal":
return new TodayLauncher(note);
case "quickSearch":
- return this.isHorizontalLayout ? new QuickSearchLauncherWidget() : null;
+ return new QuickSearchLauncherWidget(this.isHorizontalLayout);
default:
throw new Error(`Unrecognized builtin widget ${builtinWidget} for launcher ${note.noteId} "${note.title}"`);
}
diff --git a/src/public/app/widgets/quick_search_launcher.js b/src/public/app/widgets/quick_search_launcher.js
index 4a5fdc3bfb..a173bca24d 100644
--- a/src/public/app/widgets/quick_search_launcher.js
+++ b/src/public/app/widgets/quick_search_launcher.js
@@ -11,8 +11,19 @@ import QuickSearchWidget from "./quick_search.js";
*/
export default class QuickSearchLauncherWidget extends QuickSearchWidget {
+ constructor(isHorizontalLayout) {
+ super();
+ this.isHorizontalLayout = isHorizontalLayout;
+ }
+
isEnabled() {
+ if (!this.isHorizontalLayout) {
+ // The quick search widget is added somewhere else on the vertical layout.
+ return false;
+ }
+
if (utils.isMobile()) {
+ // The widget takes too much spaces to be included in the mobile layout.
return false;
}