mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
* fix: support filtering results by workspace * feat: add search button to sidebar * fix: reduce view/recent view fetching across application * feat: add channel to search listener * feat: clean + localization * chore: remove redundant code * fix: disable search * chore: trigger ci * chore: disable search in backend * test: disable search tests for now * feat: temp disable reliance on folder search * fix: add debounce to inline actions * chore: complete future if disposed * fix: clean code * chore: disable unused bloc with feature flag * fix: recent views lazy read * chore: revert podilfe change * chore: update logs * chore: update client api and collab * chore: fix tst * chore: fix test & update collab commit * chore: update collab commit * test: fix unit tests * chore: update rust toolchain 1.77 * chore: use opt-level 1 * fix: code review * chore: clippy --------- Co-authored-by: nathan <nathan@appflowy.io> Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
45 lines
1.0 KiB
Rust
45 lines
1.0 KiB
Rust
use crate::{
|
|
entities::{SearchFilterPB, SearchResultPB},
|
|
services::manager::{SearchHandler, SearchType},
|
|
};
|
|
use flowy_error::FlowyResult;
|
|
use std::sync::Arc;
|
|
|
|
use super::indexer::FolderIndexManagerImpl;
|
|
|
|
pub struct FolderSearchHandler {
|
|
pub index_manager: Arc<FolderIndexManagerImpl>,
|
|
}
|
|
|
|
impl FolderSearchHandler {
|
|
pub fn new(index_manager: Arc<FolderIndexManagerImpl>) -> Self {
|
|
Self { index_manager }
|
|
}
|
|
}
|
|
|
|
impl SearchHandler for FolderSearchHandler {
|
|
fn search_type(&self) -> SearchType {
|
|
SearchType::Folder
|
|
}
|
|
|
|
fn perform_search(
|
|
&self,
|
|
query: String,
|
|
filter: Option<SearchFilterPB>,
|
|
) -> FlowyResult<Vec<SearchResultPB>> {
|
|
let mut results = self.index_manager.search(query, filter.clone())?;
|
|
if let Some(filter) = filter {
|
|
if let Some(workspace_id) = filter.workspace_id {
|
|
// Filter results by workspace ID
|
|
results.retain(|result| result.workspace_id == workspace_id);
|
|
}
|
|
}
|
|
|
|
Ok(results)
|
|
}
|
|
|
|
fn index_count(&self) -> u64 {
|
|
self.index_manager.num_docs()
|
|
}
|
|
}
|