Skip to content

Commit

Permalink
feat(ui): add SearchNotesModal and update commands to open it or rela…
Browse files Browse the repository at this point in the history
…ted notes view

style(ui/SearchView): add getIcon method to SearchViewContainer for better component consistency
  • Loading branch information
anpigon committed Dec 10, 2024
1 parent 333f6d9 commit f7b80ba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
23 changes: 19 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 5 additions & 1 deletion src/ui/SearchView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -353,6 +353,10 @@ export class SearchViewContainer extends ItemView {
this.root?.unmount();
}

getIcon(): IconName {
return "search";
}

private renderComponent() {
this.root?.render(
<StrictMode>
Expand Down

0 comments on commit f7b80ba

Please sign in to comment.