mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 16:30:27 +00:00
refactor: rename type interfaces to use I prefix convention Standardize naming by adding I prefix to all interface types across the codebase (StreamChunk → IStreamChunk, SearchMatch → ISearchMatch, etc.). Also rename conversationStore.ts to ConversationStore.ts for consistency.
48 lines
No EOL
1.6 KiB
TypeScript
48 lines
No EOL
1.6 KiB
TypeScript
import { SearchTrigger } from "Enums/SearchTrigger";
|
|
import { Resolve } from "./DependencyService";
|
|
import { Services } from "./Services";
|
|
import type { VaultCacheService } from "./VaultCacheService";
|
|
import type { SearchStateStore } from "Stores/SearchStateStore";
|
|
import { get } from "svelte/store";
|
|
|
|
export class UserInputService {
|
|
|
|
private readonly vaultCacheService: VaultCacheService;
|
|
private readonly searchStateStore: SearchStateStore;
|
|
|
|
public constructor() {
|
|
this.vaultCacheService = Resolve<VaultCacheService>(Services.VaultCacheService);
|
|
this.searchStateStore = Resolve<SearchStateStore>(Services.SearchStateStore);
|
|
}
|
|
|
|
public get searchState() {
|
|
return this.searchStateStore.searchState;
|
|
}
|
|
|
|
public performSearch() {
|
|
const state = get(this.searchStateStore.searchState);
|
|
|
|
if (!state.active ||
|
|
state.trigger == null ||
|
|
state.query.trim().length < 3) {
|
|
this.searchStateStore.setResults([]);
|
|
return;
|
|
}
|
|
|
|
let results: string[] = [];
|
|
|
|
switch (state.trigger) {
|
|
case SearchTrigger.Tag:
|
|
results = this.vaultCacheService.matchTag(state.query).map(result => result.obj.tag);
|
|
break;
|
|
case SearchTrigger.File:
|
|
results = this.vaultCacheService.matchFile(state.query).map(result => result.obj.file.path);
|
|
break;
|
|
case SearchTrigger.Folder:
|
|
results = this.vaultCacheService.matchFolder(state.query).map(result => result.obj.folder.path);
|
|
break;
|
|
}
|
|
|
|
this.searchStateStore.setResults(results);
|
|
}
|
|
} |