diff --git a/apps/client/src/widgets/type_widgets/Empty.tsx b/apps/client/src/widgets/type_widgets/Empty.tsx
index 739731bf9..30731535a 100644
--- a/apps/client/src/widgets/type_widgets/Empty.tsx
+++ b/apps/client/src/widgets/type_widgets/Empty.tsx
@@ -1,17 +1,18 @@
-import { useEffect, useRef } from "preact/hooks";
+import { useCallback, useContext, useEffect, useRef, useState } from "preact/hooks";
import { t } from "../../services/i18n";
import FormGroup from "../react/FormGroup";
import NoteAutocomplete from "../react/NoteAutocomplete";
import "./Empty.css";
-import { refToJQuerySelector } from "../react/react_utils";
+import { ParentComponent, refToJQuerySelector } from "../react/react_utils";
import note_autocomplete from "../../services/note_autocomplete";
import appContext from "../../components/app_context";
+import FNote from "../../entities/fnote";
+import search from "../../services/search";
export default function Empty() {
return (
)
@@ -55,3 +56,29 @@ function NoteSearch() {
>
);
}
+
+function WorkspaceSwitcher() {
+ const [ workspaceNotes, setWorkspaceNotes ] = useState();
+ const parentComponent = useContext(ParentComponent);
+
+ function refresh() {
+ search.searchForNotes("#workspace #!template").then(setWorkspaceNotes);
+ }
+
+ useEffect(refresh, []);
+
+ return (
+
+ {workspaceNotes?.map(workspaceNote => (
+
parentComponent?.triggerCommand("hoistNote", { noteId: workspaceNote.noteId })}
+ >
+
+
{workspaceNote.title}
+
+ ))}
+
+ );
+}
diff --git a/apps/client/src/widgets/type_widgets_old/empty.ts b/apps/client/src/widgets/type_widgets_old/empty.ts
deleted file mode 100644
index 55487cdac..000000000
--- a/apps/client/src/widgets/type_widgets_old/empty.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import noteAutocompleteService from "../../services/note_autocomplete.js";
-import TypeWidget from "./type_widget.js";
-import appContext from "../../components/app_context.js";
-import searchService from "../../services/search.js";
-import { t } from "../../services/i18n.js";
-
-const TPL = /*html*/`
-`;
-
-export default class EmptyTypeWidget extends TypeWidget {
-
- private $autoComplete!: JQuery;
- private $results!: JQuery;
- private $workspaceNotes!: JQuery;
-
- static getType() {
- return "empty";
- }
-
- doRender() {
- // FIXME: this might be optimized - cleaned up after use since it's always used only for new tab
-
- this.$widget = $(TPL);
- this.$autoComplete = this.$widget.find(".note-autocomplete");
- this.$results = this.$widget.find(".note-detail-empty-results");
- this.$workspaceNotes = this.$widget.find(".workspace-notes");
-
- super.doRender();
- }
-
- async doRefresh() {
- const workspaceNotes = await searchService.searchForNotes("#workspace #!template");
-
- this.$workspaceNotes.empty();
-
- for (const workspaceNote of workspaceNotes) {
- this.$workspaceNotes.append(
- $('')
- .append($("
").addClass(`${workspaceNote.getIcon()} workspace-icon`))
- .append($("
").text(workspaceNote.title))
- .attr("title", t("empty.enter_workspace", { title: workspaceNote.title }))
- .on("click", () => this.triggerCommand("hoistNote", { noteId: workspaceNote.noteId }))
- );
- }
-
- this.$autoComplete.trigger("focus").trigger("select");
- }
-}