Skip to content

Commit

Permalink
fix: search entries
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Sep 12, 2024
1 parent 4fcacbf commit 4cbe2a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/renderer/src/modules/panel/cmdk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ const SearchOptions: Component = memo(({ children }) => {
<SelectTrigger size="sm">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectContent position="item-aligned">
<SelectItem
className="hover:bg-theme-item-hover"
value={`${SearchType.All}`}
Expand Down
11 changes: 5 additions & 6 deletions src/renderer/src/store/search/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { EntryModel } from "@renderer/models"
import {
EntryRelatedKey,
EntryRelatedService,
EntryService,
FeedService,
SubscriptionService,
Expand Down Expand Up @@ -40,15 +38,16 @@ class SearchActions {
}

async createLocalDbSearch() {
const [entries, feeds, subscriptions, entryRelated] = await Promise.all([
const [entries, feeds, subscriptions] = await Promise.all([
EntryService.findAll(),
FeedService.findAll(),
SubscriptionService.findAll(),
EntryRelatedService.findAll(EntryRelatedKey.FEED_ID),
])

const feedsMap = new Map(feeds.map((feed) => [feed.id, feed]))

const entriesFuse = this.createFuse(entries, ["title", "content", "description", "id"])
const feedsFuse = this.createFuse(feeds, ["title", "description", "id"])
const feedsFuse = this.createFuse(feeds, ["title", "description", "id", "siteUrl", "url"])
const subscriptionsFuse = this.createFuse(subscriptions, ["title", "category"])

return defineSearchInstance({
Expand All @@ -67,7 +66,7 @@ class SearchActions {

const processedEntries = [] as SearchResult<EntryModel, { feedId: string }>[]
for (const entry of entries) {
const feedId = entryRelated[entry.item.id]
const feedId = feedsMap.get(entry.item.feedId)?.id
if (feedId) {
processedEntries.push({ item: entry.item, feedId })
}
Expand Down

0 comments on commit 4cbe2a2

Please sign in to comment.