fix: fixed sidebar search
This commit is contained in:
@@ -383,9 +383,15 @@ const PostsList: React.FC = () => {
|
|||||||
try {
|
try {
|
||||||
const results = await window.electronAPI?.posts.search(query);
|
const results = await window.electronAPI?.posts.search(query);
|
||||||
if (results) {
|
if (results) {
|
||||||
// Map search results to PostData (search returns SearchResult with score)
|
// Fetch full PostData for each search result
|
||||||
const postIds = (results as { id: string }[]).map(r => r.id);
|
const fullPosts: PostData[] = [];
|
||||||
setSearchResults(posts.filter(p => postIds.includes(p.id)));
|
for (const result of results as { id: string }[]) {
|
||||||
|
const post = await window.electronAPI?.posts.get(result.id);
|
||||||
|
if (post) {
|
||||||
|
fullPosts.push(post as PostData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setSearchResults(fullPosts);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Search failed:', error);
|
console.error('Search failed:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user