From f7b80ba50e4bf6ef0c49de5a010e9f6ccf07f908 Mon Sep 17 00:00:00 2001 From: anpigon Date: Wed, 11 Dec 2024 01:04:51 +0900 Subject: [PATCH] feat(ui): add SearchNotesModal and update commands to open it or related notes view style(ui/SearchView): add getIcon method to SearchViewContainer for better component consistency --- src/main.ts | 23 +++++++++++++++++++---- src/ui/SearchView/index.tsx | 6 +++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 7f13623..fc227b0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -22,6 +22,7 @@ import calculateTokenCount from "./helpers/utils/calculateTokenCount"; import { createPineconeClient } from "./services/PineconeManager"; import { DEFAULT_SETTINGS, type PluginSettings } from "./settings/settings"; import { SettingTab } from "./settings/settingTab"; +import { SearchNotesModal } from "./ui/modals/SearchNotesModal"; import { RelatedNotesView, VIEW_TYPE_RELATED_NOTES, @@ -211,18 +212,32 @@ export default class SmartSeekerPlugin extends Plugin { new Notice("Please configure PineconeDB settings first"); return; } - this.openSearchView(); + new SearchNotesModal(this.app, this.settings).open(); }, }); // Add command this.addCommand({ - id: "open-related-note-chunks", - name: "Open Related Note Chunks", - callback: () => { + id: "open-related-notes-view", + name: "Open Related Notes View", + checkCallback: (checking) => { + if (checking) { + return Boolean(this.settings.pineconeApiKey && this.settings.pineconeIndexName); + } this.openRelatedNotesView(); }, }); + + this.addCommand({ + id: "open-search-view", + name: "Open Search View", + checkCallback: (checking) => { + if (checking) { + return Boolean(this.settings.pineconeApiKey && this.settings.pineconeIndexName); + } + this.openSearchView(); + }, + }); } async onload() { diff --git a/src/ui/SearchView/index.tsx b/src/ui/SearchView/index.tsx index a8704a0..9164ffb 100644 --- a/src/ui/SearchView/index.tsx +++ b/src/ui/SearchView/index.tsx @@ -9,7 +9,7 @@ import { QueryClientProvider, useMutation, } from "@tanstack/react-query"; -import { ItemView, Notice, TFile, WorkspaceLeaf } from "obsidian"; +import { IconName, ItemView, Notice, TFile, WorkspaceLeaf } from "obsidian"; import { FormEvent, StrictMode, @@ -353,6 +353,10 @@ export class SearchViewContainer extends ItemView { this.root?.unmount(); } + getIcon(): IconName { + return "search"; + } + private renderComponent() { this.root?.render(